google-code-export / nutz

Automatically exported from code.google.com/p/nutz
Apache License 2.0
1 stars 1 forks source link

web.xml配置问题 #301

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
http://code.google.com/p/nutz/wiki/mvc_web_xml
按照这里的说明
org.nutz.mvc.NutFilter会忽略.jsp

而
http://code.google.com/p/nutz/wiki/mvc_localization
这里配置本地化字符串的时候
又需要匹配.jsp
有矛盾

我现在的配置是这样的,先配置一个Servlet匹配*.do
<servlet>
    <servlet-name>nutz</servlet-name>
    <servlet-class>org.nutz.mvc.NutServlet</servlet-class>
    <init-param>
        <param-name>modules</param-name>
        <param-value>fbsms.frame.MainModule</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>nutz</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>
再配置一个Filter匹配*.jsp 用于显示本地化字符串
<filter>
    <filter-name>msgs</filter-name>
    <filter-class>org.nutz.mvc.NutFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>msgs</filter-name>
    <url-pattern>*.jsp</url-pattern>
</filter-mapping>

这两块能不能合并成一块?

Original issue reported on code.google.com by happyday...@gmail.com on 18 Oct 2010 at 1:09

GoogleCodeExporter commented 9 years ago
我觉得要这样处理:
1. 现有版本的NutFilter改名为NutFilter2
2. 恢复旧版的NutFilter

Original comment by wendal1985@gmail.com on 18 Oct 2010 at 1:34

GoogleCodeExporter commented 9 years ago
哦,要不,为 NutFilter 加一个属性吧
是不是仅仅用于显示本地化字符串

很多地方都用这个 Filter 了已经

Original comment by zozoh...@gmail.com on 18 Oct 2010 at 6:11

GoogleCodeExporter commented 9 years ago
fixed in r1629

<filter>
    <filter-name>msgs</filter-name>
    <filter-class>org.nutz.mvc.NutFilter</filter-class>
       <init-param>
        <param-name>skip-mode</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>

这样, filter 就能和 NutSerlvet 一起工作了

Original comment by zozoh...@gmail.com on 30 Oct 2010 at 4:24

GoogleCodeExporter commented 9 years ago
这样加个skip-mode后,单独只使用filter就不行了吧?要么单独��
�用NutServlet要么NutServlet和NutFilter联合使用,对吗? 
我看了半天源码感觉单独使用NutFilter好像不行了。

public void doFilter(ServletRequest req, ServletResponse resp, FilterChain 
chain)
            throws IOException, ServletException {
        if (!skipMode) {
            RequestPath path = Mvcs.getRequestPathObject((HttpServletRequest) req);
            if (null == ignorePtn || !ignorePtn.matcher(path.getUrl()).find()) {
                if (handler.handle((HttpServletRequest) req, (HttpServletResponse) resp))
                    return;
            }
        }
        // 如果已经找到对应的action,而且正确处理,并且不是donext模式,那么不会走到这里
        //更新 Request 必要的属性
        Mvcs.updateRequestAttributes((HttpServletRequest) req);
        // 本过滤器没有找到入口函数,继续其他的过滤器
        chain.doFilter(req, resp);
    }

这里skipMode如果=false 
,handler就不会hand,所以单独用filter来处理请求就不行了。

Original comment by superhan...@gmail.com on 29 Aug 2011 at 8:32