On Mon, Jan 7, 2013 at 6:14 PM, Remi VANKEISBELCK <[email protected]> wrote:
> Hi Chris,
>
> Le 7 janv. 2013 à 00:37, Chris Cheshire a écrit :
>
>> I have my web site configured to use the clean urls with no prefix (so
>> no *.action binding) and also working on implementing the login
>> interceptor from the Stripes book.
>
> Are you using DynamicMappingFilter ?
>
Yes I am. Relevant web.xml config :
<filter>
<description>Dynamically maps URLs to ActionBeans.</description>
<display-name>Stripes Dynamic Mapping Filter</display-name>
<filter-name>DynamicMappingFilter</filter-name>
<filter-class>net.sourceforge.stripes.controller.DynamicMappingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>StripesFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>StripesFilter</filter-name>
<servlet-name>StripesDispatcher</servlet-name>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>DynamicMappingFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
>>
>> For the most part it is working, except for where I have urls in the
>> format /someUrl/{someParameter}. When the login interceptor traps a
>> call to one of these actions, eg. /edit/1234, getLastUrl() is building
>> a url that looks like /edit/1234?id=1234 (id is the parameter I have
>> bound in the URL).
>
> What's getLastUrl() ? Could you post a snippet maybe (don't have the Stripes
> Book under hand... boooo bad bad bad) ?
>
public String getLastUrl() {
HttpServletRequest req = getContext().getRequest();
StringBuilder sb = new StringBuilder();
// Start with the URI and the path
String uri = (String)
req.getAttribute("javax.servlet.forward.request_uri");
String path = (String)
req.getAttribute("javax.servlet.forward.path_info");
if (uri == null) {
uri = req.getRequestURI();
path = req.getPathInfo();
}
sb.append(uri);
if (path != null) { sb.append(path); }
// Now the request parameters
sb.append('?');
Map<String,String[]> map =
new HashMap<String,String[]>(req.getParameterMap());
// Remove previous locale parameter, if present.
map.remove(MyLocalePicker.LOCALE);
// Append the parameters to the URL
for (String key : map.keySet()) {
String[] values = map.get(key);
for (String value : values) {
sb.append(key).append('=').append(value).append('&');
}
}
// Remove the last '&'
sb.deleteCharAt(sb.length() - 1);
return sb.toString();
}
>>
>> Is this just an artifact of the clean urls and binding the fields into
>> the url like that, or is there something I can do so that the field
>> name and value isn't passed also as a discrete parameter in the
>> request parameter map?
>
> Should not repeat your argument anyways if you're using some Stipes API
> (RediretcResolution.addParameter, s:link, etc.)
>
> Cheers
>
This is past the URL building phase of the Stripes API. The URL is
correctly built as /action/1234 (where 1234 is bound to the field id).
When it goes through the interceptor it hits the above function. What
is happening is that req.getRequestURI() is returning /action/1234,
and then req.getParameter map also contains a key of id, with value of
1234. The resultant url is then /action/1234?id=1234.
It seems like a problem with the DynamicMappingFilter and how it
treats bound parameters.
Chris
------------------------------------------------------------------------------
Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
and more. Get SQL Server skills now (including 2012) with LearnDevNow -
200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only - learn more at:
http://p.sf.net/sfu/learnmore_122512
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users