搜索墙首页  编程技术  java  asp  ajax  php  c/c#/c++  数据库  oracle  mysql  db2  操作系统  windows  linux  股吧
首页 > 编程 > java > Struts
 1         
1楼  aninfeel 2007-06-06

我只是直接在web.xml里加了个linster:        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

然后在WEB-INF下加了个spring的applicationContext.xml,在这个文件里定义好的been,在xwork.xml的action里的class可以直接使用它的id。但问题是applicationContext里的bean只可以使用singleton和prototype scope,我想问的是怎样才能使用request scope呢?虽然prototype好像可以满足需要。
2楼  deafwolf 2007-06-06

  <listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
  </listener>

去看spring framework开发参考手册
3楼  movingboy 2007-06-07

1.web.xml的定义必须符合Servlet 2.4标准(当然你的web服务器也要支持这个标准),例如:

<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <!-- Detailed configuration omitted -->
</web-app>


2.在applicationContext.xml中增加支持其它scope的listener(楼上已经提到了,略)

3.将bean配置成需要的scope,例如:

	<bean id="idOfBean" class="class.of.bean"
		scope="request">
		<!-- Other configuration omitted -->
	</bean>


重复一下楼上的建议:建议仔细读读Spring的手册,这些内容很容易找到的
4楼  FGhost 2007-10-18

应该还需要一个代理
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

<bean id="requestScope" scope="request">
     <aop:scoped-proxy/>
    </bean>

</beans>

 1         
您的发言将按有关规定都会存档,您须为所发表后果负责,请您遵纪守法并注意语言文明。
标题:整合webwork2和spring的scope问题
热门关注
标题回复点击
上个星期去腾讯面试一位主考官出的动脑题,当时被难住了168599
有没人和我一样厌倦了MVC框架各自定义的那些JSP标记库呢92467
Tapestry会成为Web表示层框架的主流解决方案吗?89380
JavaWeb层的下一个王者是谁?94372
艰难的抉择:SpringMVCORStruts2108326
SSH2:Struts2+Spring+Hibernate的登录25315
帮Springsecurity一个忙:为Struts2写个Plugin对Action进行权限控制59274
在Struts2中应用FreeMarker还是Velocity好?28261
LightURL??打造零配置的Struts2开发方式68256
Struts2返回XML7225
搜索墙@2009 www.pkwall.com all rights reserved QQ:276471788 [京ICP备09111534号]
声明:本站部分数据来源于网络,仅供参考,如有版权问题,请联系我们,我们将及时删除!转载本站请注明来源