本帖最后由 zhuxiankao666 于 2013-10-11 23:04:34 编辑

解决方案 »

  1.   

    com.icss.ssh.action.UserAction   userService呢!亲
    struts.xml中package的配置关于UserAction的
      

  2.   

    看看 struts 关于要跳转的action路径大小写拼写是否正确?
    UserService 有注入到 action层中吗?
      

  3.   

    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'userService' is defined
      

  4.   


    struts也是用注释做的UserAction.javapackage com.icss.ssh.action;import javax.annotation.Resource;import org.apache.struts2.convention.annotation.Action;
    import org.apache.struts2.convention.annotation.Result;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.context.annotation.Scope;
    import org.springframework.stereotype.Component;import com.icss.ssh.service.UserService;
    import com.opensymphony.xwork2.ActionSupport;
    @Component("userAction")
    @Scope("prototype")
    public class UserAction extends ActionSupport{
    @Resource(name="userService")
    private UserService userService;

    private String username;

    private String password;

    @Action(value="register",
    results={
    @Result(name="success",location="success.jsp")
    }

    )
    public String register(){
    userService.register(username, password);
    return "success";
    }


    public UserService getUserService() {
    return userService;
    } public void setUserService(UserService userService) {
    this.userService = userService;
    }
    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;
    }


    }
      

  5.   


    我用注释@component("userService"),在userAction中用@resource了
      

  6.   


    这个无所谓@component可以代替@controller,@Repository,@service
      

  7.   

    我用注释@component("userService"),在userAction中用@resource了
      

  8.   

    struts.xml 这里面有问题,没看到继承default-stuts呢?
      

  9.   


    我不用struts的xml配置文件了,我用的是注解
      

  10.   

    在你的代码中我没有看到userService组建
      

  11.   

    你在struts.xml中没有配置action吧
      

  12.   

    我不用struts的xml配置文件了,我用的是注解
      

  13.   


    能在说具体一点吗?????在实现类里加了啊,在action中也加了,你说的没看到是哪个地方没看到呢??
      

  14.   

    private UserService userService;
    这个你已经写了getter和setter方法了。注解最好还是写在setter方法上。我没在写注解的时候加过name属性。你可以试一下把name属性移掉,并把注解写在setter上面试试
      

  15.   

    注解是在jdk1.6及以上版本才能起作用的,看看你的jdk版本吧先
      

  16.   

    功力不行啊,注释没怎么去用,xml的话就能一眼出来了!
      

  17.   


    现在公司如果不是遗留项目的话,都用annotation了,不用xml
      

  18.   

    你的mysql版本,是不是这里少了一个5?
    一般都会忽略的
    <prop key="hibernate.dialect">
      org.hibernate.dialect.MySQLDialect
    </prop>
    <prop key="hibernate.dialect">
        org.hibernate.dialect.MySQL5Dialect
    </prop>
      

  19.   

    他最后说没有找到  bean,你看看配置好着没?
      

  20.   

    那就看你的bean了,它那里都报错了,好好看看与你的bean有关的一切。
    我一眼也不能揪出来的