File tree 2 files changed +26
-2
lines changed
main/java/org/springframework/web/servlet/tags/form
test/java/org/springframework/web/servlet/tags/form
2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright 2002-2013 the original author or authors.
2+ * Copyright 2002-2014 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1616
1717package org .springframework .web .servlet .tags .form ;
1818
19+ import java .io .UnsupportedEncodingException ;
1920import java .util .Map ;
2021
2122import javax .servlet .ServletRequest ;
3233import org .springframework .util .StringUtils ;
3334import org .springframework .web .servlet .support .RequestDataValueProcessor ;
3435import org .springframework .web .util .HtmlUtils ;
36+ import org .springframework .web .util .UriUtils ;
3537
3638/**
3739 * Databinding-aware JSP tag for rendering an HTML '{@code form}' whose
@@ -442,6 +444,13 @@ else if (StringUtils.hasText(servletRelativeAction)) {
442444 }
443445 else {
444446 String requestUri = getRequestContext ().getRequestUri ();
447+ String encoding = pageContext .getResponse ().getCharacterEncoding ();
448+ try {
449+ requestUri = UriUtils .encodePath (requestUri , encoding );
450+ }
451+ catch (UnsupportedEncodingException e ) {
452+ throw new JspException (e );
453+ }
445454 ServletResponse response = this .pageContext .getResponse ();
446455 if (response instanceof HttpServletResponse ) {
447456 requestUri = ((HttpServletResponse ) response ).encodeURL (requestUri );
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2002-2013 the original author or authors.
2+ * Copyright 2002-2014 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -340,6 +340,21 @@ public void testRequestDataValueProcessorHooks() throws Exception {
340340 assertFormTagClosed (output );
341341 }
342342
343+ public void testDefaultActionEncoded () throws Exception {
344+
345+ this .request .setRequestURI ("/a b c" );
346+ request .setQueryString ("" );
347+
348+ this .tag .doStartTag ();
349+ this .tag .doEndTag ();
350+ this .tag .doFinally ();
351+
352+ String output = getOutput ();
353+ String formOutput = getFormTag (output );
354+
355+ assertContainsAttribute (formOutput , "action" , "/a%20b%20c" );
356+ }
357+
343358 private String getFormTag (String output ) {
344359 int inputStart = output .indexOf ("<" , 1 );
345360 int inputEnd = output .lastIndexOf (">" , output .length () - 2 );
You can’t perform that action at this time.
0 commit comments