UrlTag extends org.apache.taglibs.standard.tag.rt.core.UrlTag { @Override public int doEndTag() throws JspException { super.setValue(EncodingUtils.encodeUrl(super.value)); return super.doEndTag(); }  @Override int doEndTag();  }
@Test public void testSimpleUrl() throws Exception { tag.doStartTag(); tag.setValue("/trunk/"); tag.setVar("var"); tag.addParameter("a", "1"); tag.addParameter("b", "2"); tag.doEndTag(); assertEquals("/trunk/?a=1&b=2", context.getAttribute("var")); }
@Test public void testUrlWithPlusSign() throws Exception { tag.doStartTag(); tag.setValue("/my+trunk/"); tag.setVar("var"); tag.addParameter("a", "1"); tag.addParameter("b", "2"); tag.doEndTag(); assertEquals("/my%2Btrunk/?a=1&b=2", context.getAttribute("var")); }
@Test public void testUrlWithHashAndSpaceSign() throws Exception { tag.doStartTag(); tag.setValue("/my# trunk/"); tag.setVar("var"); tag.addParameter("a", "1"); tag.addParameter("b", "2"); tag.doEndTag(); assertEquals("/my%23%20trunk/?a=1&b=2", context.getAttribute("var")); }
@Test public void testCrazyUrl() throws Exception { tag.doStartTag(); tag.setValue("/trunk/'/-/!/#/%/(/@/_/~/+/a b/?/=/;/:/,/$/"); tag.setVar("var"); tag.addParameter("a", "1"); tag.doEndTag(); assertEquals("/trunk/%27/-/%21/%23/%25/%28/%40/_/%7E/%2B/a%20b/%3F/%3D/%3B/%3A/%2C/%24/?a=1", context.getAttribute("var")); }