2 xiaohuihui183 xiaohuihui183 于 2015.07.26 21:41 提问

求大神看一下,我的struts2配置是否有问题

为什么不能访问登陆界面,之前好好的

web.xml

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

struts.xml

 <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
    <constant name="struts.devMode" value="false" />
    <package name="struts2" extends="struts-default" namespace="/">
        <action name="login" class="com.test.action.LoginAction">
            <result name="input">login.jsp</result>
            <result>/result.jsp</result>
            <result name="failer">/login.jsp</result>
        </action>
    </package>
</struts>    

Tomcat 报错

2015-7-26 13:38:49 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter struts2
Class: com.opensymphony.xwork2.spring.SpringObjectFactory
File: SpringObjectFactory.java
Method: getClassInstance
Line: 230 - com/opensymphony/xwork2/spring/SpringObjectFactory.java:230:-1
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:502)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:57)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4854)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5546)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1533)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1497)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1695)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:333)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1374)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1546)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1556)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1524)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException
at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:230)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:604)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:574)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:530)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:292)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:250)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:446)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:490)
... 19 more
2015-7-26 13:38:49 org.apache.catalina.core.StandardContext startInternal
严重: One or more Filters failed to start. Full details will be found in the appropriate container log file
2015-7-26 13:38:49 org.apache.catalina.core.StandardContext startInternal
严重: Context [/Struts2New] startup failed due to previous errors 

2个回答

suzunshou
suzunshou   2015.07.26 22:26

请问你的com.test.action.LoginAction里面是怎么写的

suzunshou
suzunshou   2015.07.26 22:28

login.jsp一个有斜杠一个没有

                        <result name="input">login.jsp</result>
            <result>/result.jsp</result>
            <result name="failer">/login.jsp</result>

xiaohuihui183
xiaohuihui183 回复ms小虾米: 错误在上面
2 年多之前 回复
jackson0215
jackson0215 回复xiaohuihui183: 可以把错误贴出来看看,看看就知道了
2 年多之前 回复
jackson0215
jackson0215 回复xiaohuihui183: 这个是正常的,你的拦截器都把login页面拦截了,拦截了login.jsp之后,找不到名称为login.jsp的action,所以报错了
2 年多之前 回复
xiaohuihui183
xiaohuihui183 在地址栏输入http://localhost8080/Struts2New/login.jsp出现404
2 年多之前 回复
xiaohuihui183
xiaohuihui183 这个先不管,我现在是一开始部署就报错
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片