spring - urlrewriting tuckey using Tuckey -
my project (we have spring 3) needs rewrite urls form
localhost:8888/testing/test.htm?param1=val1¶mn=valn
to
localhost:8888/nottestinganymore/test.htm?param1=val1¶mn=valn
my current rule looks like:
<from>^/testing/(.*/)?([a-z0-9]*.htm.*)$</from> <to type="passthrough">/nottestinganymore/$2</to>
but query parameters being doubled, getting param1=val1,val1 , paramn=valn,valn...please help! stuff huge pain.
to edit/add, have use-query-string=true on project , doubt can change that.
the regular expression needs tweaking. tuckey uses java regular expression engine unless specified otherwise. hence best way deal write small test case confirm if regular expression correct. e.g. tweaked example of regular expression test case below.
@test public void testregularexpression() { string regexp = "/testing/(.*)([a-z0-9]*.htm.*)$"; string url = "localhost:8888/testing/test.htm?param1=val1¶mn=valn"; pattern pattern = pattern.compile(regexp); matcher matcher = pattern.matcher(url); if (matcher.find()) { system.out.println("$1 : " + matcher.group(1) ); system.out.println("$2 : " + matcher.group(2) ); } }
the above print output follows :
$1 : test
$2 : .htm?param1=val1¶mn=valn
you can modify expression see "groups" want extract url , form target url.
Comments
Post a Comment