ssm环境配置web.xml报错The content of element type "web-app" must match "(icon?,display。。。。。

前提

最近开始捣鼓SSM框架,想搭个环境,配置到web.xml时,报了如上的错误。
虽然这个错误不影响功能,但是强迫症,看到红色报错就不舒服,于是google得知。

报错原因

web.xml 顺序不对

解决办法

  1. 去掉文件第二行这句描述(不推荐)
  2. 按正确顺序放置各标签(下附正确顺序),此法有时可能不能解决问题(但是我的解决了)
  3. 把类似,filter和filter-mapping和servlet–servlet-mapping这样的配对标签分开写,即所有的filter(servlet)写在一起,所有的filter-mapping(servlet-mapping)写在一起。

正确顺序是:
附:web.xml标签放置顺序

  • icon?
  • display-name?
  • description?
  • distributable?
  • context-param*
  • filter*
  • filter-mapping*
  • listener*
  • servlet*
  • servlet-mapping*
  • session-config?
  • mime-mapping*
  • welcome-file-list?
  • error-page*
  • taglib*
  • resource-env-ref*
  • resource-ref*
  • security-constraint*
  • login-config?
  • security-role*
  • env-entry*
  • ejb-ref*
  • ejb-local-ref

“?”表示该标签出现次数最多为1,”*”表示可以多次出现。

猜你喜欢

转载自blog.csdn.net/lin74love/article/details/80681713