日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

The Struts dispatcher cannot be found异常的解决方法

發(fā)布時間:2025/3/21 编程问答 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 The Struts dispatcher cannot be found异常的解决方法 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

系統(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)如下代碼:

  • <filter>
  • <filter-name>struts2</filter-name>
  • <filter-class>
  • org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
  • </filter-class>
  • </filter>
  • <filter-mapping>
  • <filter-name>struts2</filter-name>
  • <url-pattern>*.action</url-pattern>
  • </filter-mapping>
  • 該標(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),即:

  • <filter-mapping>
  • <filter-name>struts2</filter-name>
  • <url-pattern>*.jsp</url-pattern>
  • </filter-mapping>



  • 總結(jié)

    以上是生活随笔為你收集整理的The Struts dispatcher cannot be found异常的解决方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。