日期:2014-05-17  浏览次数:20627 次

struts2 spring的问题
struts2.xml
<?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE struts PUBLIC
     "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
     "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
<package name="mypkg" namespace="/test" extends="struts-default"> 
<action name="login" class="LoginAction">
<result name="success">/jsp/success.jsp</result>
<result name="input">/jsp/login.jsp</result>
</action>
</package>
</struts>

applicationContext.xml

<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">


<bean name="loginService" class="Action.LoginService" />
<bean name="LoginAction" class="Action.LoginAction" scope="prototype">
<property name="loginService">
<ref bean="loginService" />
</property>
</bean>
</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<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>  
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
<listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>

问题:
   struts.xml中package添加namespace属性后,action找不到
   不添加namespace属性后,可以找到action
   求高人指点一下

访问url:http://localhost:8080/myjsp/mypkg/test/login

异常log:
信息: JK: ajp13 listening on /0.0.0.0:8009
2013-12-16 21:28:43 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/22  config=null
2013-12-16 21:28:43 org.apache.catalina.startup.Catalina start
信息: Server startup in 5770 ms
2013-12-16&nbs