The Struts dispatcher cannot be found异常的解决方法
系統錯誤: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標簽沒有被找到,這一般是因為使用Struts標簽時,卻沒有相關的監聽器。Struts標簽只能在請求通過Servlet監聽器時才能被使用。。。。(實際上意思是指你在jsp頁面中使用了Struts標簽,但是沒有配置好相關的監聽器。)
解決方法:
配置:tomcat 6.0 && Struts2.1
解決過程:
使用了Struts標簽但是沒有配置監聽器,指明了我們必須要到web.xml文件中查看是否已經配置好相關監聽器。
查看監聽器配置情況,直接找到“<filter>”標簽以及“<filter-mapping>”標簽,這時我們會發現如下代碼:
該標簽中指出了Struts版本號、相關支持包的路徑等等。
此時應重點查看“<filter-mapping>”標簽,該標簽下的“<url-pattern>”標簽指明了監聽對象的url,此標簽的值為“*.action”,意思是指定監聽器監聽后綴為.action的文件,即Struts 2框架下的action文件。
此時問題已經很明了了。由于監聽器只監聽action文件,故jsp文件中的Struts標簽無法被系統所識別,所以產生500錯誤。
解決方案:
將<url-pattern>的值改為“/*”,使得監聽器能夠監聽所有的文件。
又或者再添加一個監聽器(將action改為jsp),即:總結
以上是生活随笔為你收集整理的The Struts dispatcher cannot be found异常的解决方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第十届蓝桥杯java B组—试题F 特别
- 下一篇: org.hibernate.NonUni