Here is my set up:
Specs:
Tomcat 7.0.109 jdk1.8.0_11 IDEA20232.5
When I enter the 'test5_5' method of this action, it will redirect to a 404 page.
if(NumberUtils.notNullEquals(result.getResult(), 0)){//登录失败
return LOGIN;
}
The corresponding configuration file
<action name="test" class="test" method="test5_5">
<result name="login">${page}</result>
<result name="reg">${page}</result>
<result name="doreg" type="chain">
<param name="namespace">/irdUser/login/opac</param>
<param name="actionName">opacRegist</param>
</result>
<result name="backurl" type="redirect">${backurl}</result>
<result type="redirect">${page}</result>
</action>
1.I tried to hardcode the path of the page, but it didn't help.
if(NumberUtils.notNullEquals(result.getResult(), 0)){//登录失败
page = "/fixpage/schools/user/login/opacLogin_irdxc.jsp";
return LOGIN;
}
2.I tried to redirect, but it didn't work.
if(NumberUtils.notNullEquals(result.getResult(), 0)){//登录失败
return "ceshi";
}
The login page is only one in the application and you should not use a dynamic result returned from the action which hase a location
hardcoded in the code. There's should be a getter for the parameter in the ${page}
. Such as
public String getPage() {
return page;
}
The JSP file should be contained in the web application folder, after the war file is unpackeged to the server, available to the web application and be in the web content folder. You should not use absolute path from the hard drive when specifying location. After the application is deployed the location is use absolute from the context root path.
So put your JSP to the web content folder and use absolute path from there. The context path is added automatically if you redirect to the login page.
The results that are common for all actions can be configured globally.
<global-results>
<result name="login" type="redirect">/opacLogin_irdxc.jsp</result>
</global-results>
You can learn more if you read Global results across different packages defined in struts configuration file.