SSH整合所遇到的问题(一)

来源:互联网 发布:斐讯efa中文安卓编程 编辑:程序博客网 时间:2024/05/16 04:59

一般在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的路径



0 0
原创粉丝点击