The Struts dispatcher cannot be found.
This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag.
這是使用struts2最常見的一個錯誤
我經過測試得知僵缺,我們在jsp頁面使用struts-tag這個標簽庫時菩咨,我們必須要先過action才能正確使用实辑,不然便會報錯据过!報的就是上面的錯誤踱讨,說的是struts-tags這個標簽庫必須在request被通過的時候才能使用辐啄,我們需要為struts的標簽初始化作喘,而要初始化的前提就是進入action张吉!
所以我得到轻纪,在我們先進入action后在跳轉到jsp頁面油额,在jsp頁面使用struts2標簽時不會出錯,但是如果我們直接進入jsp頁面便會出錯誤刻帚!
有些人可能沒有遇到潦嘶,那是因為你在創(chuàng)建struts2的項目時選擇的是/×,而不是*.do或者是*.action崇众。
如果你是*.do或者*.action 的方式創(chuàng)建的項目掂僵,那你要這樣錯處理才不會出錯誤航厚,當然這只是其中的一種方式:
也就是在web.xml中為struts2的的filter-mapping添加一個,把jsp放行锰蓬,不攔截jsp
等于是你訪問jsp等于是進來action幔睬,所以這樣等于是為struts2-tag標簽初始化,你再去使用就不會出錯誤了芹扭!
如果你是直接建的是/*這種struts2的項目就不需要做這一步驟麻顶!