public class User {
private String userName;
private String password;
public String getuserName() {
return userName;
}
public void setuserName(String name) {
this.userName = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}public class UserAction { private User user; public User getUser() { return user; } public void setUser(User user) { this.user = user; } public String login(){ ActionContext context = ActionContext.getContext(); Map<String, Object> session= context.getSession(); session.put("userName", user.getuserName()); System.out.println(user.getuserName()); System.out.println("登录"); return Action.SUCCESS; }}<struts> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> <constant name="struts.devMode" value="true" /> <package name="default" namespace="/" extends="struts-default"> <action name="user_*" class="jsh.struts.action.UserAction" method="{1}" > <result name="success"> success.jsp </result> <result name="error"> fail.jsp </result> </action> <action name="helloworld" class="jsh.struts.action.UserAction"> <result> index.jsp </result> </action> </package></struts>表单<form action="user_login" class="jsh.struts.action.UserAction"> 用户名:<input type="text" value="" name="user.userName"><br/> 密码:<input type="text" name="user.password"><br/> <input type= "submit" value = "登录"> </form>下面的是控制台的信息:[http-nio-8080-exec-2] ERROR com.opensymphony.xwork2.interceptor.ParametersInterceptor - Developer Notification (set struts.devMode to false to disable this message):Unexpected Exception caught setting 'user.userName' on 'class jsh.struts.action.UserAction: Error setting expression 'user.userName' with value ['jia', ]null登录
添加回答
举报
0/150
提交
取消