解决了一个问题,又来了个问题 头痛中 !  求j2ee帝解围!以下是异常
---------------------------------------------------
信息: Loading Spring root WebApplicationContext
2011-9-24 18:04:31 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginaction' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'Loginsevice' of bean class [org.xy.action.LoginAction]: Bean property 'Loginsevice' is not writable or has an invalid setter method. Did you mean 'loginservice'?
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'Loginsevice' of bean class [org.xy.action.LoginAction]: Bean property 'Loginsevice' is not writable or has an invalid setter method. Did you mean 'loginservice'?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:751)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:608)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValue(AbstractPropertyAccessor.java:49)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:74)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:57)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:970)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:729)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:416)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:290)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2011-9-24 18:04:31 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2011-9-24 18:04:31 org.apache.catalina.core.StandardContext start
严重: Context [/SSproject] startup failed due to previous errors
2011-9-24 18:04:31 org.apache.catalina.core.ApplicationContext log--------------------------------------
以下是ApplicationContext.xml
--------------------------------------
  <bean id="Loginservice" class="org.xy.service.LoginServiceimpl">
       </bean>
       
       
       <bean id="loginaction" class="org.xy.action.LoginAction">
        <property name="Loginsevice">
        <ref local="Loginservice"/>
        </property>
       
       </bean>
---------------------------------------
以下是struts.xml
---------------------------------------
<struts>
<constant name="struts.devMode" value="true"/>
<package name="demo"  extends="struts-default">

<action name="LoginAction" class="loginaction">
<result name="success">/success.jsp</result>
<result name="input">/index.jsp</result>
</action>
    
</package>
</struts>
-----------------------------------------
以下是LoginAction.java
-----------------------------------------
public class LoginAction extends ActionSupport { public String username;
public String password;
public String message;

private LoginService Loginservice;

  public LoginService getLoginservice() {
return Loginservice;
} public void setLoginservice(LoginService loginservice) {
Loginservice = loginservice;
} public String execute() throws Exception {
  /*if("xy".equalsIgnoreCase(username)&&"xy".equalsIgnoreCase(password))
{
return SUCCESS;
 


}
  else 
{
message= " login failed." ;
return INPUT;
}*/
  if(
  this.getLoginservice().login(username, password)==true)
  return SUCCESS;
  return INPUT;

 
}
----------------------------------------------------------
T.T  帮帮我这个新手吧~~~

解决方案 »

  1.   

    private LoginService Loginservice;
    我觉得就是这个命名错了,,一般命名规则是
    private LoginService loginService;
    然后自动生成get和set方法。那样才正确。你修改成那样试试看,看异常代码就是这个loginService的注入有问题。其他配置文件看着貌似没什么问题的。
      

  2.   

    不行额 还是一样的问题    我知道是spring配置文件问题,但是不知道该怎么改。。
      

  3.   

    <bean id="loginaction" class="org.xy.action.LoginAction">
      <property name="Loginsevice">
      <ref local="Loginservice"/>写错了
      

  4.   

    <bean id="loginaction" class="org.xy.action.LoginAction">
    <property name="Loginsevice">
    这里的name值要和action类中的private LoginService Loginservice;
    中的Loginservice完全一致。
    你现在写的不一致,所以出错了..
      

  5.   

    Error creating bean with name 'loginaction' defined in ServletContext resource 很明显,IOC或者DI错误!检查命名
      

  6.   

    LoginService单词写错了,少个“r”
      

  7.   

    你的配置没有错的,关键是属性的问题,应该是你写错了,楼上得兄弟说的对,你看段异常:
    Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'Loginsevice' of bean class [org.xy.action.LoginAction]: Bean property 'Loginsevice' is not writable or has an invalid setter method. Did you mean 'loginservice'?
      

  8.   

    这个应该是命名的问题,虽然你在类中写的是 Loginservice这个属性,但是不是直接访问的Loginservice属性,而是用的get set方法,根据命名规范,他去找的是loginservice,大写的自然错了