How to rewrite this url in spring mvc in java -
from= demo/user.search_candidate.form?action=clickoncandidate&userid=25
to= demo/click_candidate
enable filter in web.xml
<filter> <filter-name>urlrewritefilter</filter-name> <filter-class>org.tuckey.web.filters.urlrewrite.urlrewritefilter</filter-class> </filter> <filter-mapping> <filter-name>urlrewritefilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>request</dispatcher> <dispatcher>forward</dispatcher> </filter-mapping>
add following rule web-inf/urlrewrite.xml
<urlrewrite> <rule> <from>^/demo/api.do?method=getuser&uid=(.*)$</from> <to>/demo/api/user/$1</to> </rule> </urlrewrite>
you can use tuckey urlrewritefilter
for :
add dependency if you're using maven
<dependency> <groupid>org.tuckey</groupid> <artifactid>urlrewritefilter</artifactid> <version>4.0.3</version> </dependency>
this link can u.
Comments
Post a Comment