当我在jsp页面输入用户名和密码时,数据无法进入代码,我收到以下错误:
意外的例外设置了密码'关于class action.login,错误设置表达式'密码'有价值[' 123456',]
意外异常捕获设置'用户名' on class action.login,错误设置表达式' username'有价值的['测试',]
的login.jsp:
<body>
<s:form action="login" method="post">
<s:textfield label="username" name="username"/>
<s:password label="password" name="password"/>
<s:submit value="submit"/>
</s:form>
</body>
这是我的动作类: 的 Login.java
public class Login extends ActionSupport implements ModelDriven<User>, Preparable {
/**
* 123
*/
private static final long serialVersionUID = -2484039811971165080L;
private IUserService userService=null;
private String id;
private int pageIndex=1;
private String pageBar;
private List<User> list_t;
private User user;
public void prepare()throws Exception{
System.out.println("--prepare--");
System.out.println(id);
if(id==null||id.length()==0){
user=new User();
}else{
user=getUserService().getUserById(Integer.parseInt(id));
}
}
public String execute()throws Exception{
System.out.println("--execute--");
System.out.println(user.getId());
System.out.println(user.getPassword());
if(getUserService().isLogin(user)){
return SUCCESS;
}
return INPUT;
}
public String save()throws Exception{
if(getUserService().insertUser(user)){
return SUCCESS;
}
return ERROR;
}
public String edit(){
return SUCCESS;
}
public String update()throws Exception{
if(getUserService().updateUser(user)){
return SUCCESS;
}
return ERROR;
}
public String delete()throws Exception{
if(getUserService().deleteUser(Integer.parseInt(id))){
return SUCCESS;
}
return ERROR;
}
public String findAllUser()throws Exception{
try {
System.out.println("findAllUser");
list_t=getUserService().getAllUser();
ServletActionContext.getRequest().setAttribute("list", list_t);
} catch (Exception e) {
}
return SUCCESS;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getPageIndex() {
return pageIndex;
}
public void setPageIndex(int pageIndex) {
this.pageIndex = pageIndex;
}
public String getPageBar() {
return pageBar;
}
public void setPageBar(String pageBar) {
this.pageBar = pageBar;
}
public List<User> getList() {
return list_t;
}
public void setList(List<User> list) {
this.list_t = list;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public void setUserService(IUserService userService) {
this.userService = userService;
}
public IUserService getUserService() {
return userService;
}
public User getModel() {
// TODO Auto-generated method stub
return user;
}
}
答案 0 :(得分:0)
快速回答:
问题在于,在您的操作中,您没有声明字段“密码”,如:
private String username; //{add getters&setters too}
private String password; //{add getters&setters too}
问候:)