使用shiro配置登录以后,启动tomcat,访问首页地址http://localhost:8080/project,直接跳转到下面页面
http://localhost:8080/project/login;JSESSIONID=00520fe5-0d70-4f00-b084-0eadb040ccf3
?
typeclass="Apple-converted-space">?Status report
message
description?The requested resource () is not available.
把后面一段;JSESSIONID=xxx去掉可以访问/login登录地址,这个是怎么产生的?容我贴出来shiro的配置(部分代码):
<!-- 基于Form表单的身份验证过滤器 -->
?<bean id="formAuthenticationFilter" class="org.apache.shiro.web.filter.authc.FormAuthenticationFilter">
???? <property name="usernameParam" value="username"/>
???? <property name="passwordParam" value="password"/>
?</bean>
?<!-- Shiro的Web过滤器 -->
?<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
???? <property name="securityManager" ref="securityManager"/>??
?????<property name="loginUrl" value="/login"/>??
?????<property name="unauthorizedUrl" value="/unauthorized.jsp"/>??
???? <!-- anon:它对应的过滤器里面是空的,什么都没做,这里.do和.jsp后面的*表示参数,比方说login.jsp?main这种 -->?
???? <!-- authc:该过滤器下的页面必须验证后才能访问,它是Shiro内置的一个拦截器org.apache.shiro.web.filter.authc.FormAuthenticationFilter -->?
???? <property name="filters">
???????? <map>
???????????? <entry key="authc" value-ref="formAuthenticationFilter"/>
???????? </map>
???? </property>
???? <property name="filterChainDefinitions">
???????? <value>
???????? ??? /login=anon??
???????????? /static/**=anon??
???????????? /unauthorized.jsp = anon
???????????? /** = authc
???????? </value>
???? </property>
?</bean>
?解决办法,把红色的配置 "/login" 修改成 "login"
<property name="loginUrl" value="login"/>??
重启,OK,前台正常,只是后台报了错
Resolved SubjectContext context session is invalid.? Ignoring and creating an anonymous (session-less) Subject instance.
org.apache.shiro.session.UnknownSessionException: There is no session with id [0686ed3f-2a20-43d9-8c8c-fd55ce0e29fe]
?at org.apache.shiro.session.mgt.eis.AbstractSessionDAO.readSession(AbstractSessionDAO.java:170) ~[shiro-core-1.2.4.jar:1.2.4]
但是起码可以正常运行了。
后面这个提示的问题,网上说把sessionIdCookie名字修改一下,和jsession不一样
<bean id="sessionIdCookie" class="org.apache.shiro.web.servlet.SimpleCookie">
??????? <constructor-arg name="name" value="shiro.sesssion"/>
??? ?<property name="path" value="/"/>
??? </bean>
经检测,没有什么实际的作用,以后发现了问题,再更新,如果有知道的敬请留言。