日期:2014-05-17  浏览次数:20753 次

Spring注入action为null,先谢谢大家的帮助
struts代码

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>


<package name="*" extends="struts-default" namespace="*">
<global-results>
<result name="error">/error.jsp </result>
</global-results>
</package>
<package name="default" namespace="/" extends="struts-default">
<action name="*Form" class="com.gemway.test.action.CheckFormAction" method="{1}">
<result>index.jsp</result>
<result name="act" >index.jsp</result>
</action>
</package>



</struts>



action代码



/**  

* @Title: CheckFormAction.java 

* @Package com.gemway.test.action 

* @Description: TODO(用一句话描述该文件做什么) 

* @author  

* @date 2014-5-5 上午10:51:46 

* @version V1.0  

*/ 
package com.gemway.test.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.gemway.test.bean.UserBean;
import com.gemway.test.service.CheckFormService;
import com.gemway.test.service.impl.CheckFormServiceImpl;
import com.opensymphony.xwork2.ActionSupport;

/**   
 *    
 * 项目名称:SSHproject   
 * 类名称:CheckFormAction   
 * 类描述:   
 * 创建人:   
 * 创建时间:2014-5-5 上午10:51:46   
 * 修改人:   
 * 修改时间:2014-5-5 上午10:51:46   
 * 修改备注:   
 * @version    
 *    
 */

public class CheckFormAction extends ActionSupport {

private static final long serialVersionUID = 1L;
private UserBean userBean;
public UserBean getUserBean() {
return userBean;
}

public void setUserBean(UserBean userBean) {
this.userBean = userBean;
}


// CheckFormService checkFormService=new CheckFormServiceImpl();
CheckFormService checkFormService;

public CheckFormService getCheckFormService() {
return checkFormService;
}

public void setCheckFormService(CheckFormService checkFormService) {
this.checkFormService = checkFormService;
}

@Override
public String execute() throws Exception {
System.out.println("execute");

return null;
}

public String check() throws Exception {
try {


HttpServletRequest request=ServletActionContext.getRequest();
HttpServletResponse response=ServletActionContext.getResponse();
System.out.println("check");
String name=userBean.getUsrAccou