标签:s2sh整合
最近想整合S2SH,采用的是spring4+hibernate4+struts2+maven+MySQL+jdk1.8+tomcat7.
整个项目采用注解实现:spring、hibernate都采用注解实现.
struts.xml:
<constant name="struts.objectFactory" value="spring"/> <constant name="struts.devMode" value="true"/> <constant name="struts.configuration.xml.reload" value="true"/> <constant name="struts.serve.static.browserCache" value="false"/> <constant name="struts.i18n.encoding" value="UTF-8"/> <constant name="struts.i18n.reload" value="true"/> <constant name="struts.multipart.maxSize" value="104857600"/> <constant name="struts.enable.DynamicMethodInvocation" value="false"/> <package name="common" extends="struts-default"></package> <package name="login" namespace="/login" extends="common"> <action name="login" class="userLogin"> <result name="loginFail">fail.jsp</result> <result name="success">index.jsp</result> </action> </package>
controller中的java代码:
com.value.yun.modules.controllercom.opensymphony.xwork2.ActionSupportcom.value.yun.common.base.Encryptioncom.value.yun.modules.entity.Usercom.value.yun.modules.service.UserServicecom.value.yun.utils.StringUtilsorg.apache.struts2.ServletActionContextjavax.servlet.http.HttpServletRequestLoginController ActionSupport{ LoginController(){ System..println()} User UserService User () { } (User user) { .= user} (= ) String (){ HttpServletRequest request = ServletActionContext.()(==){ request.setAttribute()} (StringUtils.(.getLoginName())){ request.setAttribute()} (StringUtils.(.getPassword())){ request.setAttribute()} request.setAttribute(.getLoginName())request.setAttribute(Encryption.(.getPassword()))} }
上面无参构造方法是有执行的,在启动tomcat的时候执行的。
index.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <html> <head> <meta name="decorator" content="default"/> <title>欢迎来到登录界面</title> </head> <body> <h2>Hello World!</h2> <form action="${baseUrl}/login/login" method="post" class="loginForm"> <table> <tr> <th>账号:</th> <td><input type="text" name="user.loginName"></td> </tr> <tr> <th>密码:</th> <td><input type="password" name="user.password"></td> </tr> <tr> <td><button type="submit">登录</button></td> <td><button type="reset">重置</button></td> </tr> </table> </form> ${loginName}<br> ${password} </body> </html>
在点击登陆的时候,他就提示
<action name="login" class="userLogin">
这一行出错。
具体信息如下:
Unable to instantiate Action, userLogin, defined for ‘login‘ in namespace ‘/login‘userLogin - action - file:/D:/yun_systems/hua_yu/source/EASMS/target/EASMS/WEB-INF/classes/struts/login.xml:8:48
spring4+hibernate4+struts2注解,class找不到bean
标签:s2sh整合
原文地址:http://yunlian0621.blog.51cto.com/3504365/1636774