一、struts2。
跟webwork配置基本一致,主要是struts2.properties和struts.xml 2个配置文件,我的struts2.properties如下配置:
struts2.properties
struts.tag.altSyntax = true
struts.devMode = true
### These can be used to set the default HTTP and HTTPS ports
struts.url.http.port = 80
#webwork.url.https.port = 443
### This can be used to set your locale and encoding scheme
struts.custom.i18n.resources=ApplicationResources
struts.locale=zh_CN
struts.i18n.encoding=utf-8
# uses javax.servlet.context.tempdir by default
struts.multipart.parser=com.opensymphony.webwork.dispatcher.multipart.PellMultiPartRequest
#struts.multipart.saveDir=tmp
struts.multipart.saveDir=/tmp
struts.multipart.maxSize=512000000
struts.configuration.xml.reload=true
struts.objectFactory = spring
struts.xml 就是配置action了,由于设定了struts.objectFactory = spring,因此struts2会自动将action转为spring的bean,struts.xml可以直接配置我们的action路径,在action中我们只需要设置某个service文件的set方法即可调用事务管理bean。
struts.xml
xml version=”1.0″ encoding=”UTF-8″ ?>
“-//Apache Software Foundation//DTD Struts Configuration 2.0//EN”
“http://struts.apache.org/dtds/struts-2.0.dtd”>
二、spring2。
添加dist下的3个spring包,因为不知道哪些包是必须的,把lib里的包都加了,去除jakarta-commons/commons-attributes-compiler.jar、j2ee/servlet-api.jar、j2ee/jsp-api.jar,然后建立配置文件,我分了三个文件:
主配置文件
xml version=”1.0″ encoding=”UTF-8″?>
“http://www.springframework.org/dtd/spring-beans.dtd”>
…
…
xml version=”1.0″ encoding=”UTF-8″?>
“http://www.springframework.org/dtd/spring-beans.dtd”>
service/manager配置
xml version=”1.0″ encoding=”UTF-8″?>
“http://www.springframework.org/dtd/spring-beans.dtd”>
三、web.xml
有一点很重要,struts的filter需要放在最底,不然action接收的中文可能会乱码,不知道是不是这个原因,反正配置了就没有乱码了:
extremetable的filter
extremetable的filter mapping
Tags: Hibernate, Spring, Struts, 配置
近期评论