File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2013 the original author or authors.
2
+ * Copyright 2002-2014 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
16
16
17
17
package org .springframework .web .servlet .tags .form ;
18
18
19
+ import java .io .UnsupportedEncodingException ;
19
20
import java .util .Map ;
20
21
21
22
import javax .servlet .ServletRequest ;
32
33
import org .springframework .util .StringUtils ;
33
34
import org .springframework .web .servlet .support .RequestDataValueProcessor ;
34
35
import org .springframework .web .util .HtmlUtils ;
36
+ import org .springframework .web .util .UriUtils ;
35
37
36
38
/**
37
39
* Databinding-aware JSP tag for rendering an HTML '{@code form}' whose
@@ -442,6 +444,13 @@ else if (StringUtils.hasText(servletRelativeAction)) {
442
444
}
443
445
else {
444
446
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
+ }
445
454
ServletResponse response = this .pageContext .getResponse ();
446
455
if (response instanceof HttpServletResponse ) {
447
456
requestUri = ((HttpServletResponse ) response ).encodeURL (requestUri );
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2013 the original author or authors.
2
+ * Copyright 2002-2014 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -340,6 +340,21 @@ public void testRequestDataValueProcessorHooks() throws Exception {
340
340
assertFormTagClosed (output );
341
341
}
342
342
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
+
343
358
private String getFormTag (String output ) {
344
359
int inputStart = output .indexOf ("<" , 1 );
345
360
int inputEnd = output .lastIndexOf (">" , output .length () - 2 );
You can’t perform that action at this time.
0 commit comments