windwall / jfinal

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

jfinal对于tomcat <welcome-file-list> 加载失败 #8

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

如下tomcat中web.xml配置, 在访问http://localhost:8080/时, 
出现404异常, 注释jfinal相关的filter配置后, 可以正常访问.

         <filter>
        <filter-name>jfinal</filter-name>
        <filter-class>com.jfinal.core.JFinalFilter</filter-class>
        <init-param>
            <param-name>configClass</param-name>
            <param-value>com.fancool.sjcz.SjczConfig</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>jfinal</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <welcome-file-list>
        <welcome-file>/page/user/userlogin.html</welcome-file>
    </welcome-file-list>

查看相关源代码后,发现com.jfinal.core.ActionHandler中handle方法代��
�
if (target.indexOf(".") != -1) {
    return ;
}

因为在url为http://localhost:8080或http://localhost:8080/时候, 
target被定义为"/",但这里并没有针对target仅仅是"/"时进行判断,
 反而却去找相关的controller相关路由配置, 
由于无法找到"/"的路由, 所以就404了, 
个人目前修改此如下即可, 但可能不是很优雅
if (target.indexOf(".") != -1||target.equals("/")) {
    return ;
}

以上分析仅供参考, 仅提供完善jfinal框架提供引导, 
非常感谢你对国产开源软件的贡献.

Original issue reported on code.google.com by ftyc...@gmail.com on 18 Feb 2013 at 3:08

GoogleCodeExporter commented 8 years ago
补充, 正常来说该配置下访问http://localhost:8080/, 
应该定位到<welcom-file-list>中的html地址.

Original comment by ftyc...@gmail.com on 18 Feb 2013 at 3:10