作者:
liuwei1981
鏈接:
http://liuwei1981.javaeye.com/blog/216188
發表時間: 2008年07月18日
聲明:本文系JavaEye網站發布的原創博客文章,未經作者書面許可,嚴禁任何網站轉載本文,否則必將追究法律責任!
最近使用struts,在使用標簽的時候,出現了這樣一個問題。
原本使用標簽,引用方法是默認配置:
web.xml:
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
在頁面中引用:
<%@ taglib prefix="s" uri="/struts-tags"%>
由于在使用的web應用中一些特殊應用的關系,web.xml的配置改為:
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<taglib>
??<taglib-uri>struts-tags</taglib-uri>
??<taglib-location>/WEB-INF/struts2-core-2.0.11.jar</taglib-location>
?</taglib>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*.action</url-pattern>
</filter-mapping>
讓sturts過濾器只接受后綴名為action的請求,并把struts標簽配置到web.xml文件。
但在使用中,直接訪問index.jsp,出現異常:
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Strut
s tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher n
eeded for this tag. - [unknown location]
在struts2中不能直接使用jsp,引用struts2的標簽么?是否有解決的方法?希望大家能不吝賜教!
本文的討論也很精彩,瀏覽討論>>
JavaEye推薦
文章來源:
http://liuwei1981.javaeye.com/blog/216188