lishunli / nutz

Automatically exported from code.google.com/p/nutz
0 stars 0 forks source link

MVC: 访问的路径找不到 #198

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
web.xml 配置:
天行健(119588911)  18:05:34
如果是
    <servlet-mapping>
        <servlet-name>nut-servlet< rvlet-name>
        <url-pattern>.nut</url-pattern>
    < rvlet-mapping>
那没问题
天行健(119588911)  18:06:01
但如果变成
<servlet-mapping>
        <servlet-name>nut-servlet< rvlet-name>
        <url-pattern>/nut/*</url-pattern>
    < rvlet-mapping>
就有问题

Original issue reported on code.google.com by jiongs...@gmail.com on 20 May 2010 at 10:07

GoogleCodeExporter commented 9 years ago
这可能就是req.getRequestURI 和 req.getPathInfo的区别。

Original comment by jiongs...@gmail.com on 20 May 2010 at 10:08

GoogleCodeExporter commented 9 years ago
我印象中 Nutz用的是 req.getPathInfo

Original comment by wendal1985@gmail.com on 20 May 2010 at 11:02

GoogleCodeExporter commented 9 years ago
 Nutz 获取 request 的路径是逻辑:
===================================================================
public static String getRequestPath(HttpServletRequest req) {
    String path = req.getPathInfo();
    if (null == path)
        path = req.getServletPath();
    if (null == path)
        return "";
    int lio = path.lastIndexOf('.');
    if (lio > 0)
        path = path.substring(0, lio);
    return path;
}
===================================================================

更多情况请参看 wiki:  http://code.google.com/p/nutz/wiki/mvc_url_mapping

Original comment by zozoh...@gmail.com on 20 May 2010 at 4:11