ssh文字性快速叙述搭建
来源:互联网 发布:手机淘宝触屏版首页 编辑:程序博客网 时间:2024/06/05 09:27
一: 新建一web项目(score2)
二:添加spring功能,选择如下lib:
spring2 core
spring2 persistence core
spring2 aop
spring2 persistence jdbc
spring2 web
spring2 testing
hibernate3.2 core
三:添加hibernate功能
sessionFactory id:sessionFactory
datasource id: dataSource
(注意:添加common-pool.jar,去掉spring aop中asm-2.2.3.jar)
通过向导已经在app.xml中配置了一个id为sessionFactory的 bean,这时候,在配置上,
已经完成了spring和hibernate的集成
show_sql:<prop key="hibernate.show_sql">true</prop>
指定hbm文件所在路径:
<property name="mappingDirectoryLocations">
<list>
<value>classpath:com/model</value>
</list>
</property>
四:添加struts功能
需要添加的jar包
五:web启动的时候,自动启动spring
在web.xml中添加如下信息
<1>:配置contextConfigLocation参数,指定spring配置文件的位置
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:app.xml</param-value>
</context-param>
<2>:配置一监听器,启动spring
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
六:struts和spring的集成:所谓spring和struts的集成,是指将struts的action托管给spring,
也是指把struts的action交给spring管理,由spring完成action的依赖注入等工作
<controller>
<set-property property="processorClass" value="org.springframework.web.struts.AutowiringRequestProcessor" />
</controller>
<message-resources parameter="ApplicationResources" />
七:放一个log4j.properties 到src
八:struts访问控制配置
九: 配置openSesisonInView过滤器
<!-- spring提供的用来实现hibernate的opensessionInview的过滤器 -->
<filter>
<filter-name>openSessionInView</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
<!-- 通过这个参数指定打开session所用到的session工厂的名字,
如果session工厂的名字为“sessionFactory”,此参数可以不用指定
-->
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>sessionFactory</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>openSessionInView</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
十:配置字符编码过滤器
<!-- spring提供的用來統一編碼的 filter-->
<filter>
<filter-name>characterEncoding</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<!-- 使用utf-8编码 -->
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
<init-param>
<!-- 强制使用-->
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
十一:配置xdoclet
十二:使用sitemesh做布局
1、sitemesh.jar
2、web.xml添加过滤器
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>
com.opensymphony.module.sitemesh.filter.PageFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
3、模板文件放到decorators文件夹
4、WEB-INF下的decorators.xml
十三:AJAX: dwr的配置
1. dwr.jar
2、dwr的servlet
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>
org.directwebremoting.servlet.DwrServlet
</servlet-class>
<!-- This should NEVER be present in live -->
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
3、web-inf/dwr.xml
十四: 配置spring的聲明式事務處理
1、在app.xml中添加tx命名空間
2、<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
十五:使用scope为session或request的bean
1、 <!-- 可以使用scope 为request或session的bean -->
<listener>
<listener-class> org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
2、
<bean id="pageHolder"
class="org.springframework.beans.support.PagedListHolder" scope="session">
<property name="pageSize" value="5" />
<property name="maxLinkedPages" value="5" />
<!--做一个代理来匹配长生命周期的对象 -->
<aop:scoped-proxy/>
</bean>
- ssh文字性快速叙述搭建
- 快速搭建ssh框架
- 快速搭建SSH框架
- SSH框架快速搭建
- SSH框架快速搭建
- SSH矿建快速搭建
- 快速搭建一个SSH框架
- 快速搭建ssh代码篇
- 叙述
- 叙述
- 在eclipse中快速搭建SSH框架
- 快速搭建ssh项目环境的具体步骤
- MyEclipse8.6快速搭建SSH框架
- linux ssh代理 –快速搭建代理服务器
- 快速搭建ssh框架--ideamac版
- 在 Myeclipse2017 中快速搭建 SSH 详解
- SSH不那么神秘,10分钟快速搭建!
- 利用eclipse简单快速的搭建SSH框架
- Java中的事务处理
- 开始贴VB编程的学习过程
- 3d世界尽在掌握!—— directx 8.1/9 graphic 全解析
- 穷学生
- CSS样式清零
- ssh文字性快速叙述搭建
- 不改变样式的alert
- 再次写给我们这些浮躁的程序员
- Android HTTP Camera Live Preview Tutorial
- Android开发环境搭建
- 从网页上copy文字到word中
- 个人总结的CString常用用法
- hdu2159二维完全背包
- ffs算法