- 浏览: 41938 次
最近访客 更多访客>>
最新评论
-
zouruixin:
你说的完全不对路子。。。
软件行业的职业规划 -
mingo:
DaoAuthoritiesPopulator不需要继承什么基 ...
ACEGI结合LDAP进行统一用户管理 -
liaolei23@163.com:
DaoAuthoritiesPopulator 需要继承什么 ...
ACEGI结合LDAP进行统一用户管理 -
zhuchanglin:
你好,这种方法确实可行。但是存在一个问题,我如果只用数据库存储 ...
ACEGI结合LDAP进行统一用户管理 -
mingo:
下次去草原上跑马去,更酷,这次在山地上跑不起来
国庆第六、七天
听说struts2出来了,与webwork2的差别也不是很大,robbin说迁移很easy,禁不住诱惑,我也尝试了一把,然则发现其实好像没那么容易啊,下面把一些过程记下来。
1、JDK版本,首先我们用的是JDK1.4,一直不太敢使用JDK5,因为我们开发的系统很有可能还要在用户很久以前的系统上跑,怕出兼容问题,所以struts2我们只能选用其jdk4的那个版本了。放入的jar是:
xwork-j4-2.0.1.jar、struts2-core-j4-2.0.6.jar、retrotranslator-transformer-1.2.0.jar、retrotranslator-runtime-1.2.0.jar、backport-util-concurrent-3.0.jar
2、受到一个jar包的名字的引诱,就是struts2-spring-plugin-2.0.6.jar,于是将这个jar放到了lib中,出现了版本不兼容的异常,系统不能启动,于是找到源码,用jdk4重新编译了一下,好了。然后将struts-plugin.xml也放到了classes下面。这时候还是一直启动不了。郁闷。非常郁闷,找到以前的项目不停的对比。最后发现struts2-spring-plugin-2.0.6.jar这个jar完全没用,也就是说里面的那个类StrutsSpringObjectFactory对系统来说是没用的。删掉,然后将struts-plugin.xml也删掉了。最后的各种配置文件如下:
- ### Struts default properties
- ###(can be overridden by a struts.properties file in the root of the classpath)
- ###
- ### Specifies the Configuration used to configure Struts
- ### one could extend org.apache.struts2.config.Configuration
- ### to build one's customize way of getting the configurations parameters into Struts
- # struts.configuration=org.apache.struts2.config.DefaultConfiguration
- ### This can be used to set your default locale and encoding scheme
- # struts.locale=en_US
- struts.i18n.encoding=UTF-8
- ### if specified, the default object factory can be overridden here
- ### Note: short-hand notation is supported in some cases, such as "spring"
- ### Alternatively, you can provide a com.opensymphony.xwork2.ObjectFactory subclass name here
- #struts.objectFactory = spring
- #上面这句一定要注释掉。
- ### specifies the autoWiring logic when using the SpringObjectFactory.
- ### valid values are: name, type, auto, and constructor (name is the default)
- struts.objectFactory.spring.autoWire = name
- ### indicates to the struts-spring integration if Class instances should be cached
- ### this should, until a future Spring release makes it possible, be left as true
- ### unless you know exactly what you are doing!
- ### valid values are: true, false (true is the default)
- struts.objectFactory.spring.useClassCache = true
- ### if specified, the default object type determiner can be overridden here
- ### Note: short-hand notation is supported in some cases, such as "tiger" or "notiger"
- ### Alternatively, you can provide a com.opensymphony.xwork2.util.ObjectTypeDeterminer implementation name here
- ### Note: if you have the xwork-tiger.jar within your classpath, GenericsObjectTypeDeterminer is used by default
- ### To disable tiger support use the "notiger" property value here.
- #struts.objectTypeDeterminer = tiger
- #struts.objectTypeDeterminer = notiger
- ### Parser to handle HTTP POST requests, encoded using the MIME-type multipart/form-data
- # struts.multipart.parser=cos
- # struts.multipart.parser=pell
- struts.multipart.parser=jakarta
- # uses javax.servlet.context.tempdir by default
- struts.multipart.saveDir=
- struts.multipart.maxSize=2097152
- ### Load custom property files (does not override struts.properties!)
- # struts.custom.properties=application,org/apache/struts2/extension/custom
- ### How request URLs are mapped to and from actions
- #struts.mapper.class=org.apache.struts2.dispatcher.mapper.DefaultActionMapper
- ### Used by the DefaultActionMapper
- ### You may provide a comma separated list, e.g. struts.action.extension=action,jnlp,do
- struts.action.extension=action
- ### Used by FilterDispatcher
- ### If true then Struts serves static content from inside its jar.
- ### If false then the static content must be available at <context_path>/struts
- struts.serve.static=true
- ### Used by FilterDispatcher
- ### This is good for development where one wants changes to the static content be
- ### fetch on each request.
- ### NOTE: This will only have effect if struts.serve.static=true
- ### If true -> Struts will write out header for static contents such that they will
- ### be cached by web browsers (using Date, Cache-Content, Pragma, Expires)
- ### headers).
- ### If false -> Struts will write out header for static contents such that they are
- ### NOT to be cached by web browser (using Cache-Content, Pragma, Expires
- ### headers)
- struts.serve.static.browserCache=true
- ### Set this to false if you wish to disable implicit dynamic method invocation
- ### via the URL request. This includes URLs like foo!bar.action, as well as params
- ### like method:bar (but not action:foo).
- ### An alternative to implicit dynamic method invocation is to use wildcard
- ### mappings, such as <action name="*/*" method="{2}" class="actions.{1}">
- struts.enable.DynamicMethodInvocation = true
- ### Set this to true if you wish to allow slashes in your action names. If false,
- ### Actions names cannot have slashes, and will be accessible via any directory
- ### prefix. This is the traditional behavior expected of WebWork applications.
- ### Setting to true is useful when you want to use wildcards and store values
- ### in the URL, to be extracted by wildcard patterns, such as
- ### <action name="*/*" method="{2}" class="actions.{1}"> to match "/foo/edit" or
- ### "/foo/save".
- struts.enable.SlashesInActionNames = false
- ### use alternative syntax that requires %{} in most places
- ### to evaluate expressions for String attributes for tags
- struts.tag.altSyntax=true
- ### when set to true, Struts will act much more friendly for developers. This
- ### includes:
- ### - struts.i18n.reload = true
- ### - struts.configuration.xml.reload = true
- ### - raising various debug or ignorable problems to errors
- ### For example: normally a request to foo.action?someUnknownField=true should
- ### be ignored (given that any value can come from the web and it
- ### should not be trusted). However, during development, it may be
- ### useful to know when these errors are happening and be told of
- ### them right away.
- struts.devMode = true
- ### when set to true, resource bundles will be reloaded on _every_ request.
- ### this is good during development, but should never be used in production
- struts.i18n.reload=true
- ### Standard UI theme
- ### Change this to reflect which path should be used for JSP control tag templates by default
- struts.ui.theme=jsxhtml
- struts.ui.templateDir=template
- #sets the default template type. Either ftl, vm, or jsp
- struts.ui.templateSuffix=ftl
- ### Configuration reloading
- ### This will cause the configuration to reload struts.xml when it is changed
- struts.configuration.xml.reload=true
- ### Location of velocity.properties file. defaults to velocity.properties
- ###struts.velocity.configfile = velocity.properties
- ### Comma separated list of VelocityContext classnames to chain to the StrutsVelocityContext
- ###struts.velocity.contexts =
- ### Location of the velocity toolbox
- ###struts.velocity.toolboxlocation=
- ### used to build URLs, such as the UrlTag
- struts.url.http.port = 80
- struts.url.https.port = 443
- ### possible values are: none, get or all
- struts.url.includeParams = get
- ### Load custom default resource bundles
- # struts.custom.i18n.resources=testmessages,testmessages2
- ### workaround for some app servers that don't handle HttpServletRequest.getParameterMap()
- ### often used for WebLogic, Orion, and OC4J
- struts.dispatcher.parametersWorkaround = false
- ### configure the Freemarker Manager class to be used
- ### Allows user to plug-in customised Freemarker Manager if necessary
- ### MUST extends off org.apache.struts2.views.freemarker.FreemarkerManager
- #struts.freemarker.manager.classname=org.apache.struts2.views.freemarker.FreemarkerManager
- ### See the StrutsBeanWrapper javadocs for more information
- struts.freemarker.wrapper.altMap=true
- ### configure the XSLTResult class to use stylesheet caching.
- ### Set to true for developers and false for production.
- struts.xslt.nocache=false
- ### A list of configuration files automatically loaded by Struts
- struts.configuration.files=struts-default.xml,struts.xml
- #不能加载struts-plugin.xml,在classpath下面也不能有这个文件
- ### Whether to always select the namespace to be everything before the last slash or not
- struts.mapper.alwaysSelectFullNamespace=false
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE struts PUBLIC
- "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
- "http://struts.apache.org/dtds/struts-2.0.dtd">
- <struts>
- <include file="struts-default.xml" />
- <include file="struts-application.xml" />
- <include file="struts-common.xml" />
- <include file="struts-dym.xml" />
- <include file="struts-zxw.xml" />
- <include file="struts-hw.xml" />
- <include file="struts-zw.xml" />
- <include file="struts-lb.xml" />
- <include file="struts-lx.xml" />
- <include file="struts-cjh.xml" />
- <include file="struts-wyf.xml" />
- </struts>
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE struts PUBLIC
- "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
- "http://struts.apache.org/dtds/struts-2.0.dtd">
- <struts>
- <package name="default" extends="struts-default">
- <interceptors>
- <!-- Interceptor to catch exceptions and display mapped exception result -->
- <interceptor name="exceptionHandler" class="com.broadtext.framework.web.interceptor.ExceptionHandleInterceptor" />
- <interceptor name="authorizationHandler" class="com.broadtext.framework.web.interceptor.AuthorizationInterceptor" />
- <interceptor name="autowiring" class="com.opensymphony.xwork2.spring.interceptor.ActionAutowiringInterceptor"/>
- <interceptor-stack name="appDefaultStack">
- <interceptor-ref name="autowiring"/>
- <interceptor-ref name="exception"/>
- <interceptor-ref name="alias"/>
- <interceptor-ref name="servlet-config"/>
- <interceptor-ref name="prepare"/>
- <interceptor-ref name="chain"/>
- <interceptor-ref name="model-driven"/>
- <interceptor-ref name="fileUpload"/>
- <interceptor-ref name="static-params"/>
- <interceptor-ref name="params"/>
- <interceptor-ref name="conversionError"/>
- <interceptor-ref name="exceptionHandler" />
- <interceptor-ref name="authorizationHandler" />
- </interceptor-stack>
- </interceptors>
- <default-interceptor-ref name="appDefaultStack" />
- <global-results>
- <result name="appBaseError">/pages/common/appBaseError.jsp</result>
- <result name="runtimeError">/pages/common/runtimeError.jsp</result>
- <result name="unkownError">/pages/common/runtimeError.jsp</result>
- </global-results>
- </package>
- </struts>
- <bean id="userService" class="com.broadtext.cmshzhgl.security.service.impl.UserServiceImpl">
- <property name="dao" ref="baseDao"></property>
- <property name="utilService" ref="utilService"></property>
- <property name="roleService" ref="roleService"></property>
- </bean>
- public class LoginAction extends BaseAction {
- private UserService userService;
- public String login(){
- String aaa = userService.getTestString();
- System.out.println(aaa);
- return SUCCESS;
- }
- public void setUserService(UserService userService) {
- this.userService = userService;
- }
- }
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE struts PUBLIC
- "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
- "http://struts.apache.org/dtds/struts-2.0.dtd">
- <struts>
- <package name="test" extends="default" namespace="/pages/test">
- <action name="login" class="com.broadtext.cmshzhgl.security.action.LoginAction" method="login">
- <result name="success">/pages/common/currentUser.jsp</result>
- </action>
- </package>
- </struts>
总体感觉是:对于具体的开发业务的配置,xwork.xml变到struts.xml比较简单,但是spring如何注入还是比较麻烦的,要改几个文件的内容,而不是简单的将webwork和xwork改成struts就ok,主要问题struts提供了好几种spring注入的选择,弄得有些犯晕。上面我只列出其中一种配置方案,更多的配置方法慢慢再体验吧。
相关推荐
Struts2.0.6 API CHM 是一个包含Apache Struts 2框架核心API和WebWork 2 API的离线帮助文档,对于开发者来说是学习和查阅Struts2相关功能和方法的重要参考资料。CHM(Compiled Help Manual)是微软开发的一种帮助...
XWork的拦截器(Interceptor)机制是其一大亮点,拦截器可以插入到动作执行的前后,执行额外的任务,如日志记录、权限检查、事务控制等。这种设计使得业务逻辑与基础设施代码分离,提高了代码的可维护性和可扩展性。...
### Struts2.0.6配置 Struts2作为MVC框架的一部分,主要负责处理Web层的请求与响应。其核心配置文件`struts.xml`和`struts.properties`定义了框架的行为与动作映射。 #### `struts.properties`关键配置解析: - *...
是有关xwork培训的,BizFocus5.0是东方易维公司开发的一款优秀的中间件技术平台。
在 `struts-config.xml` 或 `xwork.xml` 配置文件中,配置 Action 映射,指定 URL 路径到对应的 Action 类和方法。同时,设置 Action 结果的视图路径,以便 WebWork 将其转发到相应的 JSP 页面。 ```xml ...
WebWork的这些特性被集成到Struts 2中,使得Struts 2成为了一个高效且易用的MVC框架。 **Struts 2的生命周期**: 1. 用户发起HTTP请求。 2. Struts 2 框架接收到请求,解析请求参数。 3. 拦截器链开始执行,按照...
- **社区与生态**:Struts2凭借其更广泛的社区支持和丰富的插件资源,成为了Java Web开发领域的主流框架之一,而WebWork2虽然在某些方面有其独特优势,但总体上已被Struts2所超越。 - **兼容性问题**:Struts2在与...
《Struts 2实战》结合实例介绍了Struts 2框架,主要内容包括Action、Result、Interceptor等框架组件,基于注解的配置选项等新特征,Struts 2插件 FreeMarker,如何从Struts 1和WebWork 2迁移到Struts 2,Ajax标签、...
从给定的文件信息“webwork-reference-2.2.2.pdf”中,我们可以提炼出一系列与WebWork框架相关的IT知识点。以下是对这些知识点的详细解释: ### WebWork框架概览 WebWork是一个用于Java Web应用程序开发的轻量级...
webwork的包。webwork开发者不可缺少的
Struts2.1权威指南——基于WebWork核心的MV Struts2.1权威指南——基于WebWork核心的MV Struts2.1权威指南——基于WebWork核心的MV Struts2.1权威指南——基于WebWork核心的MV
【Webwork2 简介】 WebWork是由OpenSymphony组织开发的Java企业级Web框架,专注于组件化和代码重用。...WebWork与Struts的相似之处在于Action的使用和配置方式,使得从Struts过渡到WebWork相对平滑。
《Struts 2实战》结合实例介绍了Struts 2框架,主要内容包括Action、Result、Interceptor等框架组件,基于注解的配置选项等新特征,Struts 2插件 FreeMarker,如何从Struts 1和WebWork 2迁移到Struts 2,Ajax标签、...
Webwork2 的许多创新后来被整合到 Struts2 中,进一步提升了其功能和性能。 **Direct Web Remoting (DWR)** 是一种 JavaScript 到 Java 的通信库,它允许在浏览器端直接调用服务器端的 Java 方法,从而实现 AJAX...
WebWork和Struts2是两个在Java Web开发领域中非常重要的框架,它们为构建MVC(Model-View-Controller)架构的应用程序提供了强大的支持。WebWork是早期的一个框架,后来发展成为了Struts2的核心,因此深入理解...
是学习struts 2很好的资料,这是原代码,分成两个压缩包.
不用多说了,Struts 2权威指南--基于WebWork核心的MVC开发(高清完整版),解压出来有200多M,因为权限不怎么够,我一共分了12卷,是一本不可多得的好书。第一卷附目录: 第1章 Struts 2概述,第2章 Struts 2下的Hello...
Struts2.1权威指南——基于WebWork核心的MV Struts2.1权威指南——基于WebWork核心的MV Struts2.1权威指南——基于WebWork核心的MV