问答详情
源自:4-4 Shiro过滤器

为什么登录成功后访问 http://localhost:8080/ 会报404错误?

我的shiro配置:

<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
    <property name="securityManager" ref="defaultWebSecurityManager"/>
    <property name="loginUrl" value="login.html"/>
    <property name="unauthorizedUrl" value="403.html"/>
    <property name="filterChainDefinitions">
        <value>
            <!--无论下面是否配置 / = anon 访问http://localhost:8080/ 都会报404错误-->
            / = anon
            /index.html = anon
            /login.html = anon
            /subLogin = anon
            /* = authc
        </value>
    </property>
</bean>

其他页面都正常:

这时没有登录过,直接地址栏输入:http://localhost:8080/index.html 可以正常访问

https://img2.mukewang.com/5afd1cc60001ff8204300215.jpg

点击登录输入用户名密码提交:

https://img2.mukewang.com/5afd1c80000136d403850185.jpg

提交 登录成功以后:

https://img4.mukewang.com/5afd1c8e00016b8903420224.jpg

然后把地址栏改为  http://localhost:8080 回车就报404

 https://img4.mukewang.com/5afd1c990001bbf604320334.jpg

提问者:键盘兔 2018-05-17 14:12

个回答

  • qq_慕娘3316381
    2020-10-11 11:08:30

    遇到同样问题,修改server中的server locations为第二个选项,部署到服务器发布,已经解决

  • Amon1990
    2019-11-29 10:41:51

    你这个问题解决了吗 我也遇到了这个问题

  • qq_慕侠4054085
    2019-09-10 10:34:07

    在tomcat里面的webapps少了Root,刚刚解决?

  • 慕姐3200295
    2018-06-09 17:12:22

    默认起始页要在web.xml里面配置的。

    <!-- 配置起始页 -->  
    <welcome-file-list>  	
        <welcome-file>index.html</welcome-file>  
    </welcome-file-list>


  • 键盘兔
    2018-05-21 10:41:12

    自己顶一下,我问的不是404是什么意思,请看过这个视频教程的认真看我的问题,访问的是项目根目录,根目录下有这个index.html 。我是跟着老师一步一步 做的。发现登录成功以后访问跟目录,就报404.推测是 shiro和springmvc的过滤器拦截有冲突。

  • qq_烟雨江南_9
    2018-05-17 21:21:26

    因为这个后面没有任何资源给他访问,所以就是404,404就像是空指针。没有就报错