使用shiro无法加载静态资源,控制台出现Resource interpreted as Stylesheet but transferred with MIME type text/html

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lhc_makefunny/article/details/79889632

今天学习使用shiro,在加载index.jsp页面时,js和css没有加载,页面只显示html,按F12控制台显示

Resource interpreted as Stylesheet but transferred with MIME type text/html
解决办法:在spring的配置文件中将静态资源允许匿名访问:

	<bean id="shiroFilter"
		class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
		<property name="securityManager" ref="securityManager" />
		<!-- 登录界面 -->
		<property name="loginUrl" value="/index.jsp" />
		<!-- 登录成功后的界面 -->
		<property name="successUrl" value="/views/Main.jsp" />
		<property name="unauthorizedUrl" value="/unauthorizedUrl.jsp" />
		<!-- 配置哪些页面需要受保护,以及需要的权限 .anon 可以匿名访问 .authc 需认证后才可以访问 -->
		<property name="filterChainDefinitions">
			<value>
				/index.jsp = anon
				<!--不允许匿名访问-->
				/views/** = authc
				<!--assets文件主要存放静态资源文件,允许访问即可-->
				/assets/** = anon
			</value>
		</property>
	</bean>

猜你喜欢

转载自blog.csdn.net/lhc_makefunny/article/details/79889632