Reputation: 311
When I click on this link, placed in Login.jsp
, I get an error "The requested resource is 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 I place this s:url
tag inside Home.jsp
, it 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>
Upvotes: 0
Views: 223
Reputation: 1
The id
attribute is deprecated. Use var
instead. Use namespace attribute if you have a namespace in the package. Reference context variable with #
. Don't use underscore for variable name.
<s:url var="registerUrl" namespace="/" action="registerLink" />
<s:a href="%{#registerUrl}">Register</s:a>
Upvotes: 2