struts2整合spring的问题,我找了一个上午的错,都找不出来,大家帮忙啊。。谢谢。Java code ?xml version1.0
struts2整合spring的问题,我找了一个上午的错,都找不出来,大家帮忙啊。。谢谢。
Java code <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.or[code=Java] g/dtds/struts-2.0.dtd">
<struts>
<!-- <constant name="struts.objectFactory" value="spring"/>-->
<include file="struts-default.xml"/>
<constant name="struts.custom.i18n.resources" value="globalMsges"></constant>
<package name="person" extends="struts-default">
<action name="login" class="loginAction">
<result>/index.jsp</result>
<result name="input">/pages/login.jsp</result>
</action>
</package>
</struts>
[/code]
这里是struts.xml的配置,我排错就到这里出了问题,在login中的 class 在spring配置文件中(如下)
Java code<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"><bean id="loginService" class="com.test.service.impl.LoginServiceImpl"></bean><bean id="loginAction" class="com.person.action.LoginAction" scope="prototype"> <property name="loginService"> <ref local="loginService"/> </property></bean></beans> 就会报错:
严重: Error filterStart
2009-4-30 13:57:31 org.apache.catalina.core.StandardContext start
严重: Context [/person] startup failed due to previous errors
log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
2009-4-30 13:57:31 org.apache.coyote.http11.Http11BaseProtocol start
[解决办法] Error filterStart 看到这个 应该是 Spring 过滤器的问题
在web.xml设置一下使用Spring的过滤器给所有的地址进行转码就可以了:
<filter>
<filter-name>Spring character encoding filter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Spring character encoding filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
[解决办法] <constant name="struts.objectFactory" value="spring"/>
上面那个为什么注释呢
[解决办法] 帮顶下
[解决办法] 可能是web.xml中的配置有问题,建议部署到其它的server上试试,如weblogic、jes等,可能会有更详细的错误信息。
[解决办法] 回帖是一种美德!每天回帖即可获得 10 分可用分
[解决办法] 你用tomcat 的吗 版本是不是低了
[解决办法]
引用楼主 bengben 的帖子: Java code <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.or[code=Java] g/dtds/struts-2.0.dtd"> <struts> <!-- <constant name="struts.objectFactory" value="spring"/>--> <include file="struts-default.xml"/> <constant name="struts.custom.i18n.resources" val…[解决办法] 使用struts2-spring-plugin
1.配置web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
2.指定对象工厂
struts.objectFactory = org.apache.struts2.spring.StrutsSpringObjectFactory
3.配置struts.xml和application.xml
[解决办法] 应该是配置环境出问题了,版本之间的兼容