SSH2开发回顾总结(一)

一、struts2回顾

1.web.xml

作用:用来配置过滤器,欢迎页,错误页,监听器,控制器,log4J的配置,application.xml文件的位置配置,制定中文编码UTF-8的配置等等,以下做详细总结。

a.log4j的配置(log4j是一个非常强大的log记录软件)


log4jConfigLocation
/WEB-INF/log4j.properties



log4jRefreshInterval
60000

log4j:log4jRefreshInterval为60000表示 开一条watchdog线程每60秒扫描一下配置文件的变化;

这里有一片文章详细地讲解了log4j的配置及用法。
http://blog.csdn.net/azheng270/article/details/2173430/
b.contextConfigLocation的详细解读
转:http://blog.csdn.net/zndxlxm/article/details/8711626

在web.xml中通过contextConfigLocation配置spring,contextConfigLocation
参数定义了要装入的 Spring 配置文件。

如果想装入多个配置文件,可以在
标记中用逗号作分隔符。


contextConfigLocation

/WEB-INF/applicationContext_mysql.xml

c.解决中文乱码问题


encodingFilter

org.springframework.web.filter.CharacterEncodingFilter



encoding
UTF-8


forceEncoding
true




encodingFilter
/*

d. HibernateSession开关控制配置


OpenSessionInView
org.springframework.orm.hibernate4.support.OpenSessionInViewFilter

singleSession
true

</filter>

<filter-mapping>
    <filter-name>OpenSessionInView</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

e.配置spring
为了让web应用能加载spring,设置一个侦听,通过这样一个监听器,一启动WEB应用它自动根据上面设置好的配置文件的位置把配置文件加载到内存中,为进一步使用spring中的bean做好准备


org.springframework.web.context.ContextLoaderListener



60

f. 区分servlet与struts2


ReDispatcherFilter
com.sysgrrj.common.ReDispatcherFilter

includeServlets
connector,downfile


g.使Struts2与Servlet并存解决办法 Filter转发Servlet
http://www.cnblogs.com/jifeng/archive/2010/08/28/1810706.html

http://hi.baidu.com/xingsl/item/6df32fa78c0b7112a8cfb754
解决办法:

在Struts2过滤器前增加一个过滤器,使用过滤器转发到servlet


ReDispatcherFilter
*.jsp


ReDispatcherFilter
*.action


ReDispatcherFilter
/


ReDispatcherFilter
/index


ReDispatcherFilter
/fckeditor/editor/filemanager/browser/default/connectors/jsp/connector

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

h.
在 WEB.XML配置实现浏览器根据文件类型自动打开


doc
application/msword


xls
application/msexcel


ppt
application/vnd.ms-powerpoint


wsdl
text/xml

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值