我正在寫一個過濾器來完成特定的任務,但我無法爲我的過濾器設置特定的網址格式。我的過濾器映射如下:正如我此前的預期我們可以在web.xml中使用正則表達式嗎?
<web.xml>
<filter>
<filter-name>myFilter</filter-name>
<filter-class>test.MyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>myFilter</filter-name>
<url-pattern>/org/test/*/keys/*</url-pattern>
</filter-mapping>
</web-app>
我的url-pattern [ /org/test/ * /keys/ * ]
不工作。
我打電話從瀏覽器的網址,如:
http://localhost:8080/myapp/org/test/SuperAdminReport/keys/superAdminReport.jsp
http://localhost:8080/myapp/org/test/Adminreport/keys/adminReport.jsp
http://localhost:8080/myapp/org/test/OtherReport/keys/otherReport.jsp
所以對於過濾模式上面的網址應該匹配。我怎樣才能做到這一點?
據我所知,您只能在urlpattern中使用特定文件夾的內容('path/to/my/folder/*')或特定擴展名('* .do')。 – bdares 2011-12-20 04:34:46
請參閱[本問題]中接受的答案(http://stackoverflow.com/q/26732/922954) – aishwarya 2011-12-20 04:39:55