Stripes:所有 URL 通过 StripesDispatcher 解析并转发到预编译的 JSP

发布于 2024-07-06 14:10:09 字数 359 浏览 5 评论 0原文

是否可以通过查看操作 bean 上的 @UrlBinding 注释并将这些操作 bean 转发到预编译的 JSP/servlet,而不需要定义和维护来使 StripesDispatcher 成为 Web 服务器 url 的唯一确定者。web.xml 中的配对? 基本上,我只想维护 @UrlBinding 注释作为可用 webapp 路径的唯一决定者。

也许有一种方法可以将 Jasper 指向我的 servlet 所在的位置并自动加载它们,而无需显式定义每一个?

实现这一点的具体方式并不重要,只是我离开了显式 servlet web.xml 依赖关系。

Is it possible to have the StripesDispatcher be the sole determiner of webserver urls by looking at the @UrlBinding annotations on action beans AND also having those action beans forward to pre-compiled JSPs / servlets WITHOUT needing to define and maintain <servlet> <servlet-mapping> pairs in web.xml? Basically, I just want to have to only maintain the @UrlBinding annotations as the sole determiners of available webapp paths.

Perhaps there is a way to point Jasper to where my servlets are and load them all up automatically without having to explicitly define each and every one?

The particular way in which this is achieved is not important, only that I leave the land of explicit servlet web.xml dependencies.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦魇绽荼蘼 2024-07-13 14:10:09

也许我不明白你的问题,但我会尝试一下。 AFAIK 您在 Stripes 应用程序的 web.xml 中需要的唯一映射,以使用 @URLBinding 作为 Web 应用程序中 URL 的“真实来源”:

<filter>
    <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.your.action.beans.package</param-value>
    </init-param>
    <init-param>
        <param-name>Extension.Packages</param-name>
        <param-value>com.your.extension.packages</param-value>
        </param-value>
    </init-param>
</filter>

……

<servlet>
    <servlet-name>DispatcherServlet</servlet-name>
    <servlet-class>net.sourceforge.stripes.controller.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

有了这个

<filter-mapping>
    <filter-name>StripesFilter</filter-name>
    <servlet-name>DispatcherServlet</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

<servlet-mapping>
    <servlet-name>DispatcherServlet</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>

,无需更改 Web 中的任何内容.xml 当您添加/删除操作 bean 和/或 JSP 时。

Maybe I don't understand your question, but I'll give it a go. AFAIK the only mapping you need in a Stripes app's web.xml to use @URLBinding as the 'source of truth' for URLs in your web-app:

<filter>
    <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.your.action.beans.package</param-value>
    </init-param>
    <init-param>
        <param-name>Extension.Packages</param-name>
        <param-value>com.your.extension.packages</param-value>
        </param-value>
    </init-param>
</filter>

...

<servlet>
    <servlet-name>DispatcherServlet</servlet-name>
    <servlet-class>net.sourceforge.stripes.controller.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

...

<filter-mapping>
    <filter-name>StripesFilter</filter-name>
    <servlet-name>DispatcherServlet</servlet-name>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

<servlet-mapping>
    <servlet-name>DispatcherServlet</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>

With this, there is no need to change anything in web.xml when you add/remove action beans and/or JSPs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文