Converting a Stripes application to use Friendly URLs

喜欢而已 提交于 2019-12-03 15:40:09

I've been trying out a few other things and got it working ...

I removed the existing DispatcherServlet servlet and servlet-mapping definitions in web.xml and replaced with the DynamicMappingFilter.

As a bonus, to change the way link events are passed, so that e.g.

http://localhost:8080/getting_started/hello?randomDate=

becomes

http://localhost:8080/getting_started/hello/randomDate

change the UrlBinding on the ActionBean to:

@UrlBinding("/hello/{$event}")

It didn't work for me to just replace the Dispatcher servlet with the DynamicMappingFilter (I got an error message about the DynamicMappingFilter only works in conjunction with the StripesFilter). So I have two filters and one filter-mapping configured in my web.xml now:

<filter>
    <display-name>Stripes Filter</display-name>
    <filter-name>StripesFilter</filter-name>
    <filter-class>net.sourceforge.stripes.controller.StripesFilter</filter-class>
    <init-param>
        <param-name>ActionResolver.Packages</param-name>
        <param-value>com.package.myactions.package</param-value>
    </init-param>
</filter>

<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>DynamicMappingFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
</filter-mapping>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!