glgxylrc
2009-04-02 14:32
浏览 259
已采纳

关于struts-2.1.6的struts.xml配置出现异常

struts.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">


<action
name="hello"
class="com.bjsxt.crm.web.struts2.test.VerySimpleAction"
method="hello"

/struts2/test/index.jsp

<action
name="paramstest"
class="com.bjsxt.crm.web.struts2.test.ParamsAction"

/struts2/test/params_success.jsp
/struts2/test/params_input.jsp


tomcat6.0启动就出现了下面的异常:
严重: Exception starting filter struts2
java.lang.NullPointerException
at com.opensymphony.xwork2.util.FileManager$FileRevision.needsReloading(FileManager.java:209)
at com.opensymphony.xwork2.util.FileManager.fileNeedsReloading(FileManager.java:60)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.needsReload(XmlConfigurationProvider.java:325)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.needsReload(StrutsXmlConfigurationProvider.java:168)
at com.opensymphony.xwork2.config.ConfigurationManager.conditionalReload(ConfigurationManager.java:220)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:61)
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:774)
at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:191)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4356)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:924)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:887)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2009-4-2 11:55:48 org.apache.catalina.core.StandardContext start
严重: Error filterStart

如果把

删除,则启动不会报异常,请问,不删除这句,异常如何解决?

[b]问题补充:[/b]
工程还没有开始,测试就出现这个问题了!还有一个问题就是,从JSP向Action传中文,变乱码!
[b]问题补充:[/b]
就这行配置文件,没有什么其它的了哟@!
[b]问题补充:[/b]
web.xml:

<?xml version="1.0" encoding="UTF-8"?>
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">

index.jsp


contextConfigLocation
/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml



org.springframework.web.context.ContextLoaderListener


struts2
org.apache.struts2.dispatcher.FilterDispatcher


struts2
/*

[b]问题补充:[/b]
乱码的问题解决了
就在struts.xml加入这句就行了!

不过最开始的异常没有解决哦!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

7条回答 默认 最新

  • 对java有感觉 2009-04-03 11:26
    已采纳


    value=”GBK“换成UTF-8

    点赞 评论
  • yasonisme 2009-04-02 15:35

    我用你的代码试了下没什么问题..应该是你工程的问题
    你把
    constant name="struts.configuration.xml.reload" value="true"/>
    删掉又有什么关系呢.
    一般的大一点的项目 重新加载的都会报写异常.

    点赞 评论
  • 对java有感觉 2009-04-02 22:51

    我喜欢看你工程,不想看你异常,把你工程发上来我帮你看看

    点赞 评论
  • 对java有感觉 2009-04-03 11:13

    你的struts.xml文件配置没有多大 可能是其他的问题啊

    点赞 评论
  • 对java有感觉 2009-04-03 11:13

    还是多上传写配置文件

    点赞 评论
  • 对java有感觉 2009-04-03 11:25

    乱码简单 我传个过滤器给你
    package com.mars.struts.filter;

    import java.io.IOException;

    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;

    public class Filter implements javax.servlet.Filter {

    public void destroy() {
        // TODO Auto-generated method stub
    
    }
    
    public void doFilter(ServletRequest request, ServletResponse response,
            FilterChain chain) throws IOException, ServletException {
        request.setCharacterEncoding("utf-8");
        chain.doFilter(request, response);
    }
    
    public void init(FilterConfig arg0) throws ServletException {
        System.out.println("filter--------init?");
    
    }
    

    }
    在web.xml配置文件中就写

    filter
    com.mars.struts.filter.Filter


    filter
    /*

    点赞 评论
  • 对java有感觉 2009-04-03 11:28

    把你的web.xml配置文件发上来看看

    点赞 评论

相关推荐 更多相似问题