You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Yorozuya Kazuyuki (JIRA)" <ji...@apache.org> on 2013/12/17 03:35:08 UTC
[jira] [Created] (WW-4259) Parameter is NULL when using URL
contains querystring consisted of some fields
Yorozuya Kazuyuki created WW-4259:
-------------------------------------
Summary: Parameter is NULL when using URL contains querystring consisted of some fields
Key: WW-4259
URL: https://issues.apache.org/jira/browse/WW-4259
Project: Struts 2
Issue Type: Bug
Environment: OS: Fedora 19(VM)
Struts: 2.3.16
JRE: 7.0
Tomcat: 7.0
Eclipse: 4.3.2
Reporter: Yorozuya Kazuyuki
h3. Phenomenon
1. Submitting form with parameters using URL contains querystring consisted of some fields.
{noformat}
<s:form id="testForm" action="Test.action?field1=%{field1}&field2=%{field2}">
{noformat}
2. When URL in struts tag interpreted as HTML, "action" atrribute is this.
{noformat}
action="Test.action?field1=value1&amp;field2=value2"
{noformat}
Due to duplication of "amp;", it causes "field2" to fail to recieve value,
and "field2" equals NULL always.
\\
Desired result is this.
{noformat}
action="Test.action?field1=value1&field2=value2"
{noformat}
\\
h3. Cause
Character entity reference about "&" is executed twice.
Executed points are as follow.
--------------------------------------------------------------------------------
・/core/src/main/java/org/apache/struts2/views/util/DefaultUrlHelper.java
{noformat}
String buildUrl(
String action, HttpServletRequest request, HttpServletResponse response,
Map<String, Object> params, String scheme, boolean includeContext,
boolean encodeResult, boolean forceAddSchemeHostAndPort, boolean escapeAmp
)
{noformat}
・/core/src/main/resources/template/simple/form-common.ftl
{noformat}
<#if parameters.action??>
action="${parameters.action?html}"<#rt/>
</#if>
{noformat}
--------------------------------------------------------------------------------
h3. Solution
Parameter "escapeAmp" in method "DefaultUrlHelper.buildUrl" is set "false."
patch file is this.
{noformat}
--- core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java.orig 2013-12-16 20:39:46.877161793 +0900
+++ core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java 2013-12-16 19:41:56.000000000 +0900
@@ -162,7 +162,7 @@
ActionMapping mapping = new ActionMapping(actionName, namespace, actionMethod, formComponent.parameters);
String result = urlHelper.buildUrl(formComponent.actionMapper.getUriFromActionMapping(mapping),
- formComponent.request, formComponent.response, actionParams, null, formComponent.includeContext, true);
+ formComponent.request, formComponent.response, actionParams, null, formComponent.includeContext, true, false, false);
formComponent.addParameter("action", result);
// let's try to get the actual action class and name
{noformat}
--
This message was sent by Atlassian JIRA
(v6.1.4#6159)