以前使用了SSH框架都是使用网上整理好的,最近几天好奇,突然想自己整理一份SSH框架(struts-2.5.17,spring 4.0.0,hibernate 4.0.0),这样用着也更加的得心应手,事与愿违,还是遇到了不能解决的问题,都已经几天了,百度,Google,都无济于事(扎心一样的痛),求助,希望各路神仙,多多留言啊,万分感谢
引用jar包如下
配置文件web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>ssh2</display-name>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/conf/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>log4jRefreshInterval</param-name>
<param-value>60000</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<!-- <param-value>classpath:application.xml</param-value> -->
<param-value>/WEB-INF/conf/application.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate4.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
</filter-class>
<init-param>
<param-name>config</param-name> -->
<param-value>
struts-default.xml,struts-plugin.xml,../config/struts.xml
</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/mgt/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
Struts.xml配置如下:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<constant name="struts.i18n.encoding" value="UTF-8" />
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.devMode" value="true" />
<constant name="struts.objectFactory" value="spring"></constant>
<constant name="struts.configuration.xml.reload" value="true" />
<constant name="struts.objectTypeDeterminer" value="notiger" />
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.action.extension" value="do" />
<package name="default"
namespace="/mgt"
extends="struts-default,json-default"
strict-method-invocation="false"
>
<action name="uAction" class="userAction">
<result name="success" type="redirect">/index.jsp</result>
<result name="login" type="redirect">/login.jsp</result>
</action>
</package>
</struts>
报错如下:
2018-09-02 02:43:27,411 ERROR [localhost-startStop-1] dispatcher.Dispatcher (Dispatcher.java:508) - Dispatcher initialization failed
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.opensymphony.xwork2.inject.ContainerImpl$MethodInjector.inject(ContainerImpl.java:284) ~[struts2-core-2.5.17.jar:2.5.17]
at com.opensymphony.xwork2.inject.ContainerImpl$ConstructorInjector.construct(ContainerImpl.java:417) ~[struts2-core-2.5.17.jar:2.5.17]
at com.opensymphony.xwork2.inject.ContainerBuilder$5.create(ContainerBuilder.java:253) ~[struts2-core-2.5.17.jar:2.5.17]
at com.opensymphony.xwork2.inject.Scope$2$1.create(Scope.java:52) ~[struts2-core-2.5.17.jar:2.5.17]
at com.opensymphony.xwork2.inject.ContainerBuilder$3.create(ContainerBuilder.java:118) ~[struts2-core-2.5.17.jar:2.5.17]
at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:616) ~[struts2-core-2.5.17.jar:2.5.17]
at com.opensymphony.xwork2.inject.ContainerBuilder$7.call(ContainerBuilder.java:613) ~[struts2-core-2.5.17.jar:2.5.17]
at com.opensymphony.xwork2.inject.ContainerImpl.callInContext(ContainerImpl.java:555) ~[struts2-core-2.5.17.jar:2.5.17]
at com.opensymphony.xwork2.inject.ContainerBuilder.create(ContainerBuilder.java:613) ~[struts2-core-2.5.17.jar:2.5.17]
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.createBootstrapContainer(D