直接访问login.action报错,求解
为什么写完之后,访问auth没问题,login.jsp也没问题,登陆也正常,就是单独访问login.action的时候报错,这是为什么呢? Struts Problem Report Struts has detected an unhandled exception: Messages: File: action/ManagerAction.java Line number: 50
代码:
package action;
import java.util.Map;
import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class ManagerAction extends ActionSupport implements SessionAware {
private String username;
private String password;
//需要实现sessionAware接口!!!!!
private Map<String, Object> session;//直接定义session,用来存放信息,使用put方法
/**
* 实现了sessionAware接口之后,要实现它的setSession方法,this.session=session;
*/
@Override
public void setSession(Map<String, Object> session) {
this.session=session;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String login(){
if(username.equals("admin")&&password.equals("123")){
session.put("loginfo", username);
return SUCCESS;
}else{
session.put("loginError", "用户名或密码不正确");
return ERROR;
}
}
}