The Struts dispatcher cannot be found异常的解决方法
系統(tǒng)錯誤:HTTP Status 500
異常信息:The Struts dispatcher cannot be found.? This is usually caused by using Struts tagswithout the associated filter. Struts tags are only usable when the request haspassed through its servlet filter, which initializes the Struts dispatcherneeded for this tag. - [unknown location]
上述異常信息大概意思是說:Struts標(biāo)簽沒有被找到,這一般是因為使用Struts標(biāo)簽時,卻沒有相關(guān)的監(jiān)聽器。Struts標(biāo)簽只能在請求通過Servlet監(jiān)聽器時才能被使用。。。。(實際上意思是指你在jsp頁面中使用了Struts標(biāo)簽,但是沒有配置好相關(guān)的監(jiān)聽器。)
解決方法:
配置:tomcat 6.0 && Struts2.1
解決過程:
使用了Struts標(biāo)簽但是沒有配置監(jiān)聽器,指明了我們必須要到web.xml文件中查看是否已經(jīng)配置好相關(guān)監(jiān)聽器。
查看監(jiān)聽器配置情況,直接找到“<filter>”標(biāo)簽以及“<filter-mapping>”標(biāo)簽,這時我們會發(fā)現(xiàn)如下代碼:
該標(biāo)簽中指出了Struts版本號、相關(guān)支持包的路徑等等。
此時應(yīng)重點查看“<filter-mapping>”標(biāo)簽,該標(biāo)簽下的“<url-pattern>”標(biāo)簽指明了監(jiān)聽對象的url,此標(biāo)簽的值為“*.action”,意思是指定監(jiān)聽器監(jiān)聽后綴為.action的文件,即Struts 2框架下的action文件。
此時問題已經(jīng)很明了了。由于監(jiān)聽器只監(jiān)聽action文件,故jsp文件中的Struts標(biāo)簽無法被系統(tǒng)所識別,所以產(chǎn)生500錯誤。
解決方案:
將<url-pattern>的值改為“/*”,使得監(jiān)聽器能夠監(jiān)聽所有的文件。
又或者再添加一個監(jiān)聽器(將action改為jsp),即:總結(jié)
以上是生活随笔為你收集整理的The Struts dispatcher cannot be found异常的解决方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第十届蓝桥杯java B组—试题F 特别
- 下一篇: org.hibernate.NonUni