一般在myeclipse添加sshCapacity 在workspace項目中web-inf/lib裏面沒有jar包 然而服務器tomcat的lib下有
整合struts2時候要多加入struts-spring-pluginJAR包
在web.xml中要加入struts2的核心過濾器,spring的核心監聽器
<!-- 配置Spring的核心監聽器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- 配置Struts2的核心過濾器 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
紅二代碼 表示要更改applicationContext.xml的路徑 改爲從類路徑下方法 默認情況是在lib下的
紅1,3代碼 記得檢查遠程引入類的路徑是否正確 用Ctrl按着再點擊這個類路徑看否可訪問
數據庫信息文件jdbc.properties文件 需要在applicationContext.xml中配置引入
<!-- 引入外部屬性文件 -->
<context:property-placeholder location="classpath:jdbc.properties"/>
值得注意的是:jdbc.driver=com.mysql.jdbc.Driver 要大寫D
Struts.xml中Action中class在ssh整合中只需要寫注入的bean名就行 不像單獨用struts時寫class的路徑