作者:
liuwei1981
鏈接:
http://liuwei1981.javaeye.com/blog/216188
發(fā)表時(shí)間: 2008年07月18日
聲明:本文系JavaEye網(wǎng)站發(fā)布的原創(chuàng)博客文章,未經(jīng)作者書面許可,嚴(yán)禁任何網(wǎng)站轉(zhuǎn)載本文,否則必將追究法律責(zé)任!
最近使用struts,在使用標(biāo)簽的時(shí)候,出現(xiàn)了這樣一個(gè)問(wèn)題。
原本使用標(biāo)簽,引用方法是默認(rèn)配置:
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>
在頁(yè)面中引用:
<%@ taglib prefix="s" uri="/struts-tags"%>
由于在使用的web應(yīng)用中一些特殊應(yīng)用的關(guān)系,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過(guò)濾器只接受后綴名為action的請(qǐng)求,并把struts標(biāo)簽配置到web.xml文件。
但在使用中,直接訪問(wèn)index.jsp,出現(xiàn)異常:
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的標(biāo)簽么?是否有解決的方法?希望大家能不吝賜教!
本文的討論也很精彩,瀏覽討論>>
JavaEye推薦
文章來(lái)源:
http://liuwei1981.javaeye.com/blog/216188