ssh文字性快速叙述搭建

一: 新建一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>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值