web.xml文件:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/*.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>配置:
<bean id="userDao" class="cc.user.dao.UserDAO">
</bean>

<bean id="userBo" class="cc.user.bo.UserBo"></bean>

<bean id="userService" class="cc.user.service.impl.UserServiceImpl">
<property name="userDao" ref="userDao"></property>
</bean>

<bean id="userAction" class="cc.user.action.UserAction">
<property name="userService" ref="userService"></property>
<property name="userBo" ref="userBo"></property>
</bean>
java文件:
public class UserAction extends ActionSupport{
UserBo userBo; 
UserService userService;
String result="";
/**
 * 验证用户登录
 * @return
 */
public String checkUser(){
String i=userService.checkUser(userBo);
result=i;
return SUCCESS;
}
@JSON(serialize=false)
public UserBo getUserBo() {
return userBo;
}
public void setUserBo(UserBo userBo) {
this.userBo = userBo;
}
@JSON(serialize=false)
public UserService getUserService() {
return userService;
}
public void setUserService(UserService userService) {
this.userService = userService;
} public String getResult() {
return result;
} public void setResult(String result) {
this.result = result;
}

}谢谢大家帮忙,看看小弟那里配错了,只有User userservice =new UserService 才能用,也不报错,控制台打印:
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.config.ConfigurationManager  - Checking ConfigurationProviders for reload.
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler  - Entering nullPropertyValue [target=[com.opensymphony.xwork2.DefaultTextProvider@12a73d9], property=struts]
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.config.ConfigurationManager  - Checking ConfigurationProviders for reload.
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler  - Entering nullPropertyValue [target=[com.opensymphony.xwork2.DefaultTextProvider@12a73d9], property=struts]
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.config.ConfigurationManager  - Checking ConfigurationProviders for reload.
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.DefaultActionProxy  - Creating an DefaultActionProxy for namespace /user and action name check
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.interceptor.I18nInterceptor  - intercept '/user/check' { 
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.interceptor.I18nInterceptor  - applied invocation context locale=zh_CN
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.interceptor.I18nInterceptor  - before Locale=zh_CN
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler  - Entering nullPropertyValue [target=[cc.user.action.UserAction@ec898a, com.opensymphony.xwork2.DefaultTextProvider@12a73d9], property=struts]
69047 [http-8080-1] DEBUG org.apache.struts2.interceptor.FileUploadInterceptor  - Bypassing /user/check
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.interceptor.StaticParametersInterceptor  - Setting static parameters {}
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.interceptor.ParametersInterceptor  - Setting params NONE
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.interceptor.ParametersInterceptor  - Setting params userBo.id => [ 1234 ] userBo.pass => [ 1234 ] 
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler  - Entering nullPropertyValue [target=[cc.user.action.UserAction@ec898a, com.opensymphony.xwork2.DefaultTextProvider@12a73d9], property=userBo]
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter  - Property: id
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter  - Class: cc.user.bo.UserBo
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter  - field-level type converter for property [id] = none found
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter  - Property: userBo.id
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter  - Class: cc.user.action.UserAction
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter  - global-level type converter for property [id] = none found
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter  - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@182c132]
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter  - Property: pass
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter  - Class: cc.user.bo.UserBo
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter  - field-level type converter for property [pass] = none found
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter  - Property: userBo.pass
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter  - Class: cc.user.action.UserAction
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter  - global-level type converter for property [pass] = none found
69047 [http-8080-1] DEBUG com.opensymphony.xwork2.conversion.impl.XWorkConverter  - falling back to default type converter [com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter@182c132]
69047 [http-8080-1] DEBUG org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor  - Validating /user/check with method checkUser.
69063 [http-8080-1] DEBUG com.opensymphony.xwork2.validator.ValidationInterceptor  - Invoking validate() on action cc.user.action.UserAction@ec898a
69063 [http-8080-1] DEBUG com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil  - cannot find method [validateCheckUser] in action [cc.user.action.UserAction@ec898a]
69063 [http-8080-1] DEBUG com.opensymphony.xwork2.interceptor.PrefixMethodInvocationUtil  - cannot find method [validateDoCheckUser] in action [cc.user.action.UserAction@ec898a]
69063 [http-8080-1] DEBUG com.opensymphony.xwork2.DefaultActionInvocation  - Executing action method = null
69063 [http-8080-1] DEBUG com.opensymphony.xwork2.config.ConfigurationManager  - Checking ConfigurationProviders for reload.
69078 [http-8080-1] DEBUG freeer.cache  - org/apache/struts2/dispatcher/error.ftl[zh_CN,UTF-8,parsed] using cached since jar:file:/D:/Work/Tomcat%206.0/webapps/cweb/WEB-INF/lib/struts2-core-2.1.8.1.jar!/org/apache/struts2/dispatcher/error.ftl didn't change.
69078 [http-8080-1] DEBUG freeer.beans  - Key 'location' was not found on instance of java.lang.NullPointerException. Introspection information for the class is: {getClass=public final native java.lang.Class java.lang.Object.getClass(), localizedMessage=java.beans.PropertyDescriptor@1ecb84b5, cause=java.beans.PropertyDescriptor@78a21497, getMessage=public java.lang.String java.lang.Throwable.getMessage(), getCause=public java.lang.Throwable java.lang.Throwable.getCause(), equals=public boolean java.lang.Object.equals(java.lang.Object), hashCode=public native int java.lang.Object.hashCode(), class=java.beans.PropertyDescriptor@3c588ba8, fillInStackTrace=public synchronized native java.lang.Throwable java.lang.Throwable.fillInStackTrace(), stackTrace=java.beans.PropertyDescriptor@b9249eb2, message=java.beans.PropertyDescriptor@85e125ae, java.lang.Object@b9b8d0=freeer.ext.beans.MethodMap@1762fc7, getStackTrace=public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace(), setStackTrace=public void java.lang.Throwable.setStackTrace(java.lang.StackTraceElement[]), java.lang.Object@1478a2d={public void java.lang.Throwable.setStackTrace(java.lang.StackTraceElement[])=[Ljava.lang.Class;@3aef16, public boolean java.lang.Object.equals(java.lang.Object)=[Ljava.lang.Class;@126c6ea, public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()=[Ljava.lang.Class;@cd43ce, public java.lang.Throwable java.lang.Throwable.getCause()=[Ljava.lang.Class;@1eb0c6, public java.lang.String java.lang.Throwable.getMessage()=[Ljava.lang.Class;@e7b3f2, public final native java.lang.Class java.lang.Object.getClass()=[Ljava.lang.Class;@1d709a5, public java.lang.String java.lang.Throwable.getLocalizedMessage()=[Ljava.lang.Class;@ba6c13, public synchronized native java.lang.Throwable java.lang.Throwable.fillInStackTrace()=[Ljava.lang.Class;@10d9151, public synchronized java.lang.Throwable java.lang.Throwable.initCause(java.lang.Throwable)=[Ljava.lang.Class;@1bf68a9, public native int java.lang.Object.hashCode()=[Ljava.lang.Class;@1706eb7, public java.lang.String java.lang.Throwable.toString()=[Ljava.lang.Class;@74db2c}, toString=public java.lang.String java.lang.Throwable.toString(), initCause=public synchronized java.lang.Throwable java.lang.Throwable.initCause(java.lang.Throwable), printStackTrace=freeer.ext.beans.MethodMap@1e16483, getLocalizedMessage=public java.lang.String java.lang.Throwable.getLocalizedMessage()}

解决方案 »

  1.   

    你看看 UserAction  中的 userservice是否为空 ?这个信息看着好难受
      

  2.   

    Service 的set方法根本不走,应该是空的,是不是spring根本没有注入?service的的方法更不走了
      

  3.   

    你的dao层貌似就注入失败了。你注入的还是接口么!
      

  4.   

    Dao没用接口,直接一个类实现
      

  5.   

    UserBo userBo; 
    UserService userService;
    是两个接口类吗
      

  6.   


    业务层的时候是配置DAO的
      

  7.   

    这些要等到spring好使了再弄,现在主要是每一层的注入都是失败的
      

  8.   


    你看看你的service里面有set方法没有?
      

  9.   

    谢谢大家的热情,愚蠢的错误 ,web.xml配置中,spring的xml文件路径错了