眼尖的来看看吧。我快崩溃了。struts2简单配置
本帖最后由 AA5279AA 于 2013-01-25 13:59:55 编辑 做一个小项目,本来没问题。
后来换了个一个开发编辑工具,就开始出问题了。。
大家帮忙看看问题出在哪了吧?
今天遇到的问题太多,头痛,实在解决不了了。
下面是简化的,登陆页面:
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="login" method="get">
姓名:<input name="name" type="text"></input><br>
密码:<input name="password" type="password"></input><br>
<input type="submit" value="注册"></input>
</form>
</body>
</html>
<package name="myPackage" namespace="/resources" extends="base">
<!-- <default-class-ref class=""/> -->
<global-results>
<result name="success">/resources/loginsuccess.jsp</result>
<result name="error">/resources/error.html</result>
</global-results>
<action name="login" method="logins" class="cn.test.springTest.LoginAction">
</action>
<action name="register" method="execute" class="cn.test.springTest.RegisterAction">
</action>
</package>
public class LoginAction extends ActionSupport{
String name;
String password;
public String logins(){
//ActionContext ac = ActionContext.getContext();
HttpServletRequest request=ServletActionContext.getRequest();
try {
request.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
request.setAttribute("name", name);
request.setAttribute("password", password);
System.out.println("in login");
if((name!=null)&&(password!=null)){
System.out.println("用户信息已经接受");
System.out.println("用户名为"+name+",密码为:"+password);
return SUCCESS;
}else{
System.out.println("用户名或者密码为空");
return ERROR;
}
}
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;
}
}
[解决办法]