bjl710640289
bjl710640289
2014-12-12 03:11

报错!!!找不到action中welcome方法,求大神们赐教!

  • java
  • ssh2

HTTP Status 500 - The welcome() is not defined in action class com.opensymphony.xwork2.ActionSupport


type Exception report

message The welcome() is not defined in action class com.opensymphony.xwork2.ActionSupport

description The server encountered an internal error that prevented it from fulfilling this request.

exception

java.lang.IllegalArgumentException: The welcome() is not defined in action class com.opensymphony.xwork2.ActionSupport
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:454)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:280)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:243)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

 LoginAction类代码:
package com.test.bean.web;

import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;
import com.test.bean.entity.base.User;
import com.test.bean.service.base.UserManager;

/**

系统登录
@author Administrator
*
*/
@SuppressWarnings("serial")
public class LoginAction extends ActionSupport implements Preparable{

private String username; //登录用户名
private String password; //登录密码

@Autowired
private UserManager userManager; //操作员管理Session
public String welcome(){
return list();
}

public String list(){
return SUCCESS;
}

public String login(){
//获取用户信息
User user=userManager.getUser(username, password);
if(user == null){
addActionError("用户名或密码不正确!");
return SUCCESS;

}
ActionContext actioncontext=ActionContext.getContext();
actioncontext.getSession().put("user", user);
return "index";
}
public String loginRedirect(){
return "index";
}
public String logout(){
//退出时清空session中的内容
ActionContext actioncontext=ActionContext.getContext();
actioncontext.getSession().put("user", null);
return SUCCESS;
}

/**

防止重复提示错误信息 */ public void prepare(){ // TODO Auto-generated method stub clearErrorsAndMessages(); } public void setUsername(String username){ this.username=username; } public void setPassword(String password){ this.password=password; } }
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答

为你推荐