strtuts2配置

strut2.0 与 hibernate spring 的整合
[color=red]1.在 web.xml 文件中的配置[/color]

[quote]<!--应用上下文 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
[color=green]/WEB-INF/applicationContext.xml[/color]</param-value>
[color=blue]<!-- 如果applicationContext.xml在src目录下存放,绿色位置应该为
classpath:applicationContext.xml-->[/color]
</context-param>

<!-- spring的监听器,以便在启动时就自动加载spring的配置 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

<!-- 使用filter加载struts.xml文件 --> <filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>

<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> [/quote]

[color=red]2.在src下添加一个 struts.xml文件 [/color]

[quote]<?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>
<constant name="struts.i18n.encoding" value="GBK" />
[color=red]<!-- 将action托管给spring --> [/color]
<constant name="struts.objectFactory" value="spring" />
<include file="struts-default.xml" />
[color=red]<!--strut2上传文件保存的地址-->[/color]
<constant name="struts.multipart.saveDir" value="c:\"></constant>
<package name="struts2" extends="struts-default">
<action name="index" class="goods">
<interceptor-ref name="defaultStack" />
<result name="index">/jsp/index.jsp</result>
</action>
</package>
</struts> [/quote]

[color=red]3.在spring 配置文件中配置[/color]
[quote] <bean name="goods" class="com.accp.ssh.action.GoodsAction"
scope="prototype">
</bean> [/quote]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值