spring跟struts的整合步驟

2021-07-15 10:29:06 字數 1056 閱讀 3633

1.加入jar包

複製檔案。

複製struts2-spring-plugin-x-x-x.jar和spring.jar到web-inf/lib目錄下。其中的x對應了spring的版本號。還需要複製commons-logging.jar、struts2-core-2.3.4.1.jar檔案到web-inf/lib目錄下。

2. 配置web.xml

<?xml version="1.0" encoding="utf-8"?>

xmlns:xsi=""

game.cai

encodingfilter

org.springframework.web.filter.characterencodingfilter

encoding

utf-8

forceencoding

true

encodingfilter

/*struts2

org.apache.struts2.dispatcher.ng.filter.strutsprepareandexecutefilter

struts2

/*org.springframework.web.context.contextloaderlistener

contextconfiglocation

hibernateopensessioninviewfilter

org.springframework.orm.hibernate3.support.opensessioninviewfilter

struts2cleanupfilter

org.apache.struts2.dispatcher.actioncontextcleanup

index.html

index.htm

index.jsp

default.html

default.htm

default.jsp

3.新增struts2-spring整合的外掛程式:struts2-spring-plugin-2.0.12.jar,如果不使用這個外掛程式,則需要在struts.xml裡面配置:

Struts 2整合Spring 經典

struts 2整合spring struts 2框架為整合其他技術提供了良好的可擴充套件性,可以通過外掛程式的方式來實現同spring技術的整合。13.2.1 整合步驟 struts 2框架整合spring很簡單,下面是整合的步驟。1 複製檔案。複製struts2 spring plugin x ...

struts2整合spring步驟

1.匯入spring的核心包 spring.jar 二者整合開發所需的包 struts spring plugin 2.0.6.jar 2.修改web.xml配置檔案 配置spring載入上下文時的 org.springframework.web.context.contextloaderliste...

解決struts2 1 6整合Spring亂碼問題

今天用struts2.1.6整合spring的時候,發現在提交中文到資料庫的時候出現亂碼,剛開始還以為是資料庫用的字符集有誤呢,誰知不管怎麼改就是不行,於是通過debug發現,在提交到action的時候,便出現了亂碼,終於找到問題所在,解決它也就在眼前了,呵呵。這個是我以前沒有解決的web.xml配...