当前位置: 代码迷 >> Java Web开发 >> struts2 指定class就会报错解决思路
  详细解决方案

struts2 指定class就会报错解决思路

热度:5418   发布时间:2016-04-10 22:57:23.0
struts2 指定class就会报错
如果我的配置文件这么写启动服务器没有没有问题
<package name="default" namespace="/" extends="struts-default">
        <action name="hello">
            <result name="success">
                /Hello.jsp
            </result>
        </action>
    </packag>
但是如果像下面,这么写就会有问题,IndexAction3这个类我也编好了,class指定的路径也正确,在路径下也能找到IndexAction3.class这个文件,不过一启动服务器就会提示错误
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
        <action name="index" class="com.bjsxt.struts2.action.IndexAction3" >
            <result name="success">
                /ActionIntroduction.jsp
            </result>
        </action>
启动服务器就会提示错误的代码为
SEVERE: Exception starting filter struts2
Unable to load configuration. - action - file:/E:/Exceam/structs20300action/WebRoot/WEB-INF/classes/struts.xml:25:77
Caused by: Action class [com.bjsxt.struts2.action.IndexAction3] not found - action - file:/E:/Exceam/structs20300action/WebRoot/WEB-INF/classes/struts.xml:25:77
二月 18, 2014 11:06:32 上午 org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
二月 18, 2014 11:06:32 上午 org.apache.catalina.core.StandardContext start
SEVERE: Context [/test] startup failed due to previous errors
二月 18, 2014 11:06:32 上午 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/test] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@452fb4]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@3f09f4]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
二月 18, 2014 11:06:32 上午 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/test] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@a68bf1]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@2da07a]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
二月 18, 2014 11:06:32 上午 org.apache.catalina.startup.HostConfig deployDescriptor
------解决方案--------------------
  <action name="androidupdate_list" class="androidUpdateAction" method="doList">
<result name="success">/jsps/androidupdate/androidUpdateList.jsp</result>
        </action>
           加一个method 
------解决方案--------------------
IndexAction3 代码呢,是否缺少继承SupportAction呢
------解决方案--------------------
可能原因:
1,你的IndexAction大小写问题。
2,你的IndexAction中没有execute方法,而你也没有在action中配置method
------解决方案--------------------
引用:
Quote: 引用:

IndexAction3 代码呢,是否缺少继承SupportAction呢

package com.bjsxt.struts2.front.action.IndexAction3;

import com.opensymphony.xwork2.ActionSupport;

public class IndexAction3 extends ActionSupport {
public String execute(){
return "success";
}

}


配置文件中是 
  <action name="index" class="com.bjsxt.struts2.action.IndexAction3" >
类中是                        com.bjsxt.struts2.front.action.IndexAction3
------解决方案--------------------
引用:
配置文件中是 
  <action name="index" class="com.bjsxt.struts2.action.IndexAction3" >
类中是                        com.bjsxt.struts2.front.action.IndexAction3

谢谢您的耐心回答,问题解决了,呵呵,问题是我们创建JSP不是有两个选项吗?一个是Basic templates 令一个是advanced templates  我把JSP换成Basic templates  错误就没有了 

jsp模板的问题,不是配置的问题吗?
  相关解决方案