Forms Struts 1登录页面始终返回404
我已经设法进入了我的登录页面,但是一旦我提供了我的凭证并想进入成功页面,我总是会得到404 我的struts-config.xml文件Forms Struts 1登录页面始终返回404,forms,login,struts1,Forms,Login,Struts1,我已经设法进入了我的登录页面,但是一旦我提供了我的凭证并想进入成功页面,我总是会得到404 我的struts-config.xml文件 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="LoginForm" type="com.myselflearning.MyActionForm"/>
</form-beans>
<global-exceptions>
</global-exceptions>
<global-forwards>
<forward name="welcome" path="/Welcome.do"/>
</global-forwards>
<action-mappings>
<action input="/login.jsp" name="LoginForm" path="/login" scope="session" validate="true" type="com.myselflearning.MyAction">
<forward name="success" path="/success.jsp" redirect="true" />
<forward name="failure" path="/failure.jsp" redirect="true" />
</action>
<action path="/Welcome" forward="/welcomeStruts.jsp"/>
</action-mappings>
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
<message-resources parameter="MessageResource"/>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>
包com.myselflearning
导入javax.servlet.http.HttpServletRequest
导入org.apache.struts.action.ActionErrors;
导入org.apache.struts.action.ActionForm;
导入org.apache.struts.action.ActionMapping;
导入org.apache.struts.action.ActionMessage
public class MyActionForm extends ActionForm {
/**
*
*/
private static final long serialVersionUID = -8713356513481803825L;
private String username;
private String password;
public ActionErrors validate (ActionMapping mapping, HttpServletRequest request)
{
ActionErrors errors = new ActionErrors();
if (username == null || username.trim().equals(""))
{
errors.add("username", new ActionMessage("error.username"));
}
if (password == null || password.trim().equals(""))
{
errors.add("password", new ActionMessage("error.passworld"));
}
return errors;
}
public MyActionForm()
{
super();
}
public String getUsername()
{
return this.username;
}
public void setUsername(String username)
{
this.username = username;
}
public String getPassword()
{
return this.password;
}
public void setPassword(String password)
{
this.password = password;
}
}
我可能做struts的时间还不够长(还有一个要求是1.1),但它看起来很小,但基本面出了问题
一旦我验证了我的凭证,我想要看到的就是success.jsp页面
非常感谢您的帮助,最亲切的问候,是否有
success.jsp
页面?还请注意您的属性名称中的passworld
拼写错误。是的,有一个success.jsp页面……它只是说“干得好”……这就是我为什么没有把它放在那里的原因。。。
package com.myselflearning;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class MyAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
MyActionForm myActionForm = (MyActionForm) (form);
if (myActionForm.getUsername().equals(myActionForm.getPassword())) {
return mapping.findForward("success");
} else {
return mapping.findForward("failure");
}
}
}
public class MyActionForm extends ActionForm {
/**
*
*/
private static final long serialVersionUID = -8713356513481803825L;
private String username;
private String password;
public ActionErrors validate (ActionMapping mapping, HttpServletRequest request)
{
ActionErrors errors = new ActionErrors();
if (username == null || username.trim().equals(""))
{
errors.add("username", new ActionMessage("error.username"));
}
if (password == null || password.trim().equals(""))
{
errors.add("password", new ActionMessage("error.passworld"));
}
return errors;
}
public MyActionForm()
{
super();
}
public String getUsername()
{
return this.username;
}
public void setUsername(String username)
{
this.username = username;
}
public String getPassword()
{
return this.password;
}
public void setPassword(String password)
{
this.password = password;
}
}