webwork2+spring+hibernate终于成功啦
来源:互联网 发布:360度产品展示js 编辑:程序博客网 时间:2024/04/29 03:30
webwork2+spring+hibernate终于成功配置出来啦,兴奋一下!
总结一下:
1. web.xml中<servlet>标签要位于<listener>标签之后,否则会报错
2. 关于<listener>的配置如下(关于webwork与spring融合)
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>com.atlassian.xwork.ext.ResolverSetupServletContextListener</listener-class>
</listener>
org.springframework.web.context.ContextLoaderListener是spring必需的
com.atlassian.xwork.ext.ResolverSetupServletContextListener是外部解析器所需要的,作用是通过ServletContext来取出spring的ApplicationContext,作为WebWork与spring的“桥梁”。
然后,在xwork.xml中的<package>标签中加externalReferenceResolver="com.atlassian.xwork.ext.SpringServletContextReferenceResolver",这个的作用是从applicationContext.xml(是spring的配置文件)中解析外部引用的bean,同时添加一个拦截器com.opensymphony.xwork.interceptor.ExternalReferencesInterceptor
具体代码中如下:
<interceptors>
<interceptor name="reference-resolver" class="com.opensymphony.xwork.interceptor.ExternalReferencesInterceptor" />
<interceptor-stack name="modelParamsStack">
<interceptor-ref name="params" />
<interceptor-ref name="model-driven" />
<interceptor-ref name="reference-resolver" />
</interceptor-stack>
</interceptors>
最后,在需要使用spring bean的action中添加bean的外部应用功能,具体代码如下:
<action name="login" class="action.LoginAction">
<external-ref name="userDAO">userDAOProxy</external-ref> //此处,<external-ref>标签内容在同一行,否则出错
<result name="success" type="dispatcher">
<param name="location">/main.jsp</param>
</result>
<result name="loginfail" type="dispatcher">
<param name="location">/error.jsp</param>
</result>
<interceptor-ref name="modelParamsStack" />
</action>
3. applicationContext.xml的配置(spring与hibernate融合)
此出注意jar问题
4. hibernate数据库映射
user是SQL Server2000的关键字,不能作为表名,这可是惨痛的教训阿!
还有表一定要设计好主键
- webwork2+spring+hibernate终于成功啦
- Spring+Hibernate+Webwork2整合成功!
- Webwork2结合Spring, Hibernate
- Webwork2+Spring+Hibernate体验
- webwork2+spring+hibernate入门完全配置指南(1)(原创)
- webwork2+spring+hibernate入门完全配置指南(2)(原创)
- 今天第一个WebService终于发布成功啦,分享一下
- webwork2.2.2 终于发布了
- Webwork2结合Spring, Hibermate
- Spring接管webwork2/Struts2
- webwork2.x 集成 spring
- spring+hibernate+jbpm整合成功
- 成功整合spring+hibernate+jbpm
- spring+hibernate+jbpm整合成功
- spring+hibernate+jbpm整合成功
- spring+hibernate+jbpm整合成功
- spring+hibernate+Oracle9i+CLOB(成功)
- spring+hibernate+jbpm整合成功
- InstallAnywhere 5.5 Enterprise使用指南
- 网站项目管理规范手册
- 2008北京奥运最感人的一幕
- Oracle执行参数化SQL语句和存储过程
- netsh命令的一些解释
- webwork2+spring+hibernate终于成功啦
- 使用SWIG和Python对C/C++进行单元测试(二)
- spring小实例
- 发布标准是什么?可以修改吗?
- Ubuntu Linux系统上的三款超强监视工具
- 锁初探(sqlserver 2005)
- 澄清几个ASP.NET中的概念(cookie,Session,ViewState)
- (转)牢记!SQL Server数据库开发的二十一条军规(SQL收藏)
- J2ME基础篇