SSH整合时applicationContext.xml、struts.xml、web.xml的配置问题:

SSH整合时applicationContext.xml、struts.xml、web.xml的配置问题:

一:
applicationContext.xml出现问题:
1、 导入四个约束:window–preferences–xml catalog–add–Location–File system–(tx)(aop)(context)(beans)最新.xsd
–选择schemaLocation–完成。
eg:
Location: C:\Users\S\Desktop\编程笔记\J2EE\spring-framework-4.2.4.RELEASE\schema\aop\spring-aop-4.2.xsd
Key type: Schema location
Key: http://www.springframework.org/schema/aop

2、applicationContext.xml的design视图下,选中beans–右击–edit namespace --(xsi必须先加入)–add–Specify New Namespace–Location Hint–Select XML CataLog entry–选择刚才导入的四个约束,
eg:
Prefix:tx
Namespace: http://www.springframework.org/schema/tx
Location Hint:http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
最后效果:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
	http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
	http://www.springframework.org/schema/aop   
    http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
	http://www.springframework.org/schema/context  
    http://www.springframework.org/schema/context/spring-context-4.2.xsd  
	http://www.springframework.org/schema/beans 
	http://www.springframework.org/schema/beans/spring-beans-4.2.xsd">
	
	
    <bean id="TestAction" class="action.TestAction">
      <property name="user" ref="user"></property>
     
    </bean>   。。。
    </beans>

也可直接复制最后效果,但需进行第一步,如版本不同,需要改版本号

二:
struts.xml出现问题报错:

window–preferences–xml catalog–add–Location–File system–
选择struts-2.0.dtd所在位置
eg:
Location:C:\Users\S\Desktop\编程笔记\J2EE\struts-2.0.dtd
Key types:Public Id
Key: -//Apache Software Foundation//DTD Struts Configuration 2.0//EN
OK。
最终效果:

<?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.resources" value="properties/myMessages"/>
<constant name="struts.i18n.encoding" value="UTF-8"></constant>


 <constant name="struts.devMode" value="true" />

<constant name="struts.objectFactory" value="spring" ></constant>

<package name="bookcode"  extends="struts-default">
   <action name="TestAction_*" class="TestAction" method="{1}">
   <result name="index">/index.jsp</result>
	<result name="success">/success.jsp</result>
  
   </action>
   </package>
   </struts>

三:
web.xml出现问题:Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
   </listener>

<listener-class>中间Ctrl+shift+T,打开open type,输入ContextLoaderListener,选第一个,
选add source,选external source,添加C:\Users\S\Desktop\编程笔记\J2EE\spring-framework-4.2.4.RELEASE\libs\spring-web-4.2.4.RELEASE-sources.jar,
再找public class ContextLoaderListener extends ContextLoader implements ServletContextListener ,
选中ContextLoaderListener右击,copy qualified name,再粘贴

最后效果:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
	xmlns="http://java.sun.com/xml/ns/javaee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
	
	
<!--	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>
	
  <display-name></display-name>	

  <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>
  
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值