用的是struts2框架,又是该死的404。求大神帮忙.话说我就只有五分了。。 5
LoginAction.javapackagecom;importcom.opensymphony.xwork2.ActionSupport;publicclassLog...
LoginAction.java
package com;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport{
private String name;
private String password;
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public String getPassword(){
return password;
}
public void setPassword(String password){
this.password = password;
}
public String execute() throws Exception{
if(getName().equals("admin")&&getPassword().equals("123"))
return SUCCESS;
else
return ERROR;
}
}
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.custom.i18n.resources" value="messageResources" />
<package name="Struts 2 " extends="struts-default" >
<action name="login" class="com.LoginAction">
<result name="input">/login.jsp</result>
<result name="success">/success.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>
</struts>
login.jsp 展开
package com;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport{
private String name;
private String password;
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public String getPassword(){
return password;
}
public void setPassword(String password){
this.password = password;
}
public String execute() throws Exception{
if(getName().equals("admin")&&getPassword().equals("123"))
return SUCCESS;
else
return ERROR;
}
}
struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<constant name="struts.custom.i18n.resources" value="messageResources" />
<package name="Struts 2 " extends="struts-default" >
<action name="login" class="com.LoginAction">
<result name="input">/login.jsp</result>
<result name="success">/success.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>
</struts>
login.jsp 展开
2个回答
展开全部
jsp页面用s标签,action属性中,应该不要后缀吧?直接login。很久没用struts2了,记不清了。
可以看下以下连接:
http://wonengchuangzaoqij.blog.163.com/blog/static/3716743920117311120461/
可以看下以下连接:
http://wonengchuangzaoqij.blog.163.com/blog/static/3716743920117311120461/
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询