struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hudson (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (WW-4843) DefaultUrlHelper().buildUrl() not outputting port when used as parameter
Date Wed, 06 Sep 2017 10:18:00 GMT

    [ https://issues.apache.org/jira/browse/WW-4843?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16155145#comment-16155145
] 

Hudson commented on WW-4843:
----------------------------

SUCCESS: Integrated in Jenkins build Struts-master-JDK7 #25 (See [https://builds.apache.org/job/Struts-master-JDK7/25/])
WW-4843 DefaultUrlHelper().buildUrl() not outputting port when used as (amashchenko: rev 0b9e68ed16341c585d48d301ceacfb9e74438552)
* (edit) core/src/main/java/org/apache/struts2/views/util/DefaultUrlHelper.java
* (edit) core/src/test/java/org/apache/struts2/views/util/DefaultUrlHelperTest.java


> DefaultUrlHelper().buildUrl() not outputting port when used as parameter
> ------------------------------------------------------------------------
>
>                 Key: WW-4843
>                 URL: https://issues.apache.org/jira/browse/WW-4843
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.3.33
>            Reporter: k918912
>            Assignee: Lukasz Lenart
>             Fix For: 2.5.14
>
>
> This is related to WW-1950.
> If you use the method DefaultUrlHelper().buildUrl() and set forceAddSchemeHostAndPort
to true Struts2 does not always add the port. This is a problem if you intend to use the output
as a parameter.
> Example code:
> {code:java}
> Map<String, Object> parameters = new HashMap<String, Object>();
> String backUrlParameters = new DefaultUrlHelper().buildUrl("someurl.html", getServletRequest(),
getServletResponse(), null, null, true, false, true, true);
> parameters.put("backUrl", backUrlParameters);
> String backUrl = new DefaultUrlHelper().buildUrl("someurl2.html", getServletRequest(),
getServletResponse(), parameters, null, false, false, false, false);
> {code}
> The resulting parameter appended to backUrl does not have the port, even with setting
forceAddSchemeHostAndPort to true.
> Resulting URL:
> http://localhost:8080/someurl2.html?backUrl=http%3A%2F%2Flocalhost%2Fsomeurl.html
> My current workaround is to use:
> {code:java}
> String backUrlParameters = new DefaultUrlHelper().buildUrl("someurl.html", getServletRequest(),
getServletResponse(), null, getServletRequest().getScheme(), true, false, true, true);
> {code}
> This gives Struts2 the same scheme that is currently used but makes it think that there
could be a change. Result is that the port in the parameter URL is appended.
> My environment is Struts2 2.3.33 but I didn't see a code change in that area between
2.3 and 2.5, nonetheless I only selected the version I actually tested this on.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message