Element filtername is not allowed here-web.xml version="3.0"-intellij idea

背景:最近在使用IntellijIdea2016搭建项目的时候,在web.xml中出现了element filtername is not allowed here的错误。

原因:总体来讲,后来查出来的原因是web.xml头部的配置有错误的,当然网上也有说各种原因的。

解决办法:更换web.xml头部(代码中前4行)

我目前的配置如下,如果遇到该问题可以参考如下:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
  3. xsi:schemaLocation= "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  4. id= "WebApp_ID" version= "3.0">
  5. <!-- 配置Spring配置文件路径 -->
  6. <context-param>
  7. <param-name>contextConfigLocation </param-name>
  8. <param-value>
  9. classpath:applicationContext.xml
  10. </param-value>
  11. </context-param>
  12. <!-- 配置Spring上下文监听器 -->
  13. <listener>
  14. <listener-class>org.springframework.web.context.ContextLoaderListener </listener-class>
  15. </listener>
  16. <!-- 配置Spring字符编码过滤器 -->
  17. <filter>
  18. <filter-name>encodingFilter </filter-name>
  19. <filter-class>org.springframework.web.filter.CharacterEncodingFilter </filter-class>
  20. <init-param>
  21. <param-name>encoding </param-name>
  22. <param-value>UTF-8 </param-value>
  23. </init-param>
  24. <init-param>
  25. <param-name>forceEncoding </param-name>
  26. <param-value>true </param-value>
  27. </init-param>
  28. </filter>
  29. <filter-mapping>
  30. <filter-name>encodingFilter </filter-name>
  31. <url-pattern>/* </url-pattern>
  32. </filter-mapping>
  33. <!-- 配置log4j配置文件路径、检测日志配置文件变化 -->
  34. <context-param>
  35. <param-name>log4jConfigLocation </param-name>
  36. <param-value>classpath:log4j.properties </param-value>
  37. <param-name>log4jRefreshInterval </param-name>
  38. <param-value>30000 </param-value>
  39. </context-param>
  40. <!-- 配置Log4j监听器 -->
  41. <listener>
  42. <listener-class>org.springframework.web.util.Log4jConfigListener </listener-class>
  43. </listener>
  44. <!-- 首页 -->
  45. <welcome-file-list>
  46. <welcome-file>/index.jsp </welcome-file>
  47. </welcome-file-list>
  48. <!-- 错误页 -->
  49. <error-page>
  50. <error-code>404 </error-code>
  51. <location>/error/404.jsp </location>
  52. </error-page>
  53. <error-page>
  54. <error-code>500 </error-code>
  55. <location>/error/500.jsp </location>
  56. </error-page>
  57. </web-app>

资料参考:http://stackoverflow.com/questions/17563756/element-listener-class-not-allowed-in-my-web-xml

http://blog.csdn.net/cor_twi/article/details/51063541

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值