jsp - s:url link returns 404 "The requested resource is not available" -
when click on link, placed in login.jsp, error "the requested resource not available."
<s:url id="register_url" action="registerlink" /> <s:a href="%{register_url}"> register </s:a> login.jsp
<%@ page language="java" contenttype="text/html; charset=utf-8"%> <%@ taglib prefix="s" uri="/struts-tags"%> <!doctype html "> <html> <head> <title>biblioteka</title> </head> <body> <s:url id="register_url" action="registerlink" /> <s:a href="%{register_url}"> register </s:a> <div class="login-div"> <s:actionerror escape="false" /> <s:actionmessage escape="false" /> <s:form action="login" method="post"> <s:textfield name="memberbean.email" label="e-mail" /> <s:password name="memberbean.password" label="fjalëkalimi" /> <s:submit value="dërgo" /> </s:form> </div> </body> </html> also, if place s:url tag inside home.jsp, links perfectly.
the content of struts.xml
<?xml version="1.0" encoding="utf-8" ?> <!doctype struts public "-//apache software foundation//dtd struts configuration 2.5//en" "http://struts.apache.org/dtds/struts-2.5.dtd"> <struts> <constant name="struts.enable.dynamicmethodinvocation" value="true" /> <constant name="struts.devmode" value="true" /> <constant name="struts.custom.i18n.resources" value="applicationresources"/> <package name="default" namespace="/" extends="struts-default"> <interceptors> <interceptor class="org.ikubinfo.biblioteka.interceptor.logininterceptor" name="logininterceptor"> </interceptor> <interceptor-stack name="loginstack"> <interceptor-ref name="logininterceptor" /> <interceptor-ref name="defaultstack" /> </interceptor-stack> </interceptors> <!-- login action --> <action name="login" class="org.ikubinfo.biblioteka.controller.loginaction"> <result name="error">/web-inf/view/login.jsp</result> <result name="success" type="redirect">home</result> </action> <!-- home link action --> <action name="home" class="org.ikubinfo.biblioteka.controller.loginaction" method="home"> <interceptor-ref name="loginstack" /> <result name="error">/web-inf/view/login.jsp</result> <result name="success">/web-inf/view/home.jsp</result> </action> <!-- logout action --> <action name="logout" class="org.ikubinfo.biblioteka.controller.loginaction" method="logout"> <result>/web-inf/view/login.jsp</result> </action> <!-- register action --> <action name="register" class="org.ikubinfo.biblioteka.controller.registeraction" method="execute"> <result name="error">/web-inf/view/register.jsp</result> <result name="input">/web-inf/view/register.jsp</result> <result name="success">/web-inf/view/registrationsuccess.jsp</result> </action> <!-- register link --> <action name="registerlink" class="org.ikubinfo.biblioteka.controller.registeraction" method="redirect"> <result>/web-inf/view/register.jsp</result> </action> </package>
the id attribute deprecated. use var instead. use namespace attribute if have namespace in package. reference context variable #. don't use underscore variable name.
<s:url var="registerurl" namespace="/" action="registerlink" /> <s:a href="%{#registerurl}">register</s:a>
Comments
Post a Comment