struts spring整合測試

2021-04-12 21:49:23 字數 1192 閱讀 5449

struts+spring整合有3種方式,通過查閱資料得知,將servlet action 委託給spring來管理的這種方式優勢最為顯著.本次struts+spring整合測試就是採用委託的方法。

實施步聚:

首先在struts-config.xml檔案中註冊spring外掛程式,如下所示。

**

<

plug-in

classname="org.springframework.web.struts.contextloaderplugin"

>

<

set-property

property="contextconfiglocation"

/>

plug-in

>

......   

<

action

attribute="userform"

input="/user.jsp"

name="userform"

path="/user"

scope="request"

type="org.springframework.web.struts.delegatingactionproxy"

validate="false"

/>

>

.....  

......   

<

bean

name="/user"

class="com.wiley.struts.action.useraction"

singleton="false"

>

<

property

name="manage"

>

<

refbean="manage"

/>

property

>

bean

>

......  

到此基本的配置工作完成了

在測試的過程中遇到servlet action無效,但控制台沒有任何的提示,翻遍整個網路,e文看得是一知半解,中文資料很少,對我來說有價值的更少,將log4j增加上去後再次測試,原來是contextloaderplugin沒有找到。在使用myeclipse搭建spring環境時,請務必將spring-web也匯入。

最後將spring-web加入後測試成功。

struts spring整合測試

b url 百事通資訊網 url b struts spring整合有3種方式,通過查閱資料得知,將servlet action 委託給spring來管理的這種方式優勢最為顯著.本次struts spring整合測試就是採用委託的方法。實施步聚 首先在struts config.xml檔案中註冊sp...

struts spring 整合方式

1.第一種實現方法 1 將 struts 的業務邏輯控制器類配置在 spring 的配置檔案中,業務邏輯控制器中引用的業務類一併注入。注意,必須將業務邏輯控制器類配置為 scope prototype 示例如下 2 在 struts.xml 或者等效的 struts2 配置檔案中配置 action ...

struts spring 整合方式

1.第一種實現方法 1 將 struts 的業務邏輯控制器類配置在 spring 的配置檔案中,業務邏輯控制器中引用的業務類一併注入。注意,必須將業務邏輯控制器類配置為 scope prototype 示例如下 2 在 struts.xml 或者等效的 struts2 配置檔案中配置 action ...