[ https://issues.apache.org/jira/browse/WW-4843?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Lukasz Lenart updated WW-4843: ------------------------------ Fix Version/s: (was: 2.6) 2.5.14 > 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 > 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)