jsp 页面都放在了 web-inf文件夹下
shiro过滤器[ <!-- 11Shiro的Web过滤器 -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"/>
<property name="loginUrl" value="/login"/>
<property name="successUrl" value="/"/>
<property name="unauthorizedUrl" value="/unauthorized.jsp"/>
<!--<property name="filters">-->
<!--<util:map>-->
<!--<entry key="sysUser" value-ref="sysUserFilter"/>-->
<!--</util:map>-->
<!--</property>-->
<!--Shiro过滤链的定义-->
<!-- anon:例子/admins/**=anon 没有参数,表示可以匿名使用。-->
<property name="filterChainDefinitions">
<value>
/ui/** = anon
/user/login = anon
/login = anon
/unauthorized = anon
/** = user
</value>
</property>
</bean>
controller层
<!--配置渲染器-->
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<!--结果视图的前缀-->
<property name="prefix" value="/WEB-INF/jsp/"/>
<!--结果视图的后缀-->
<property name="suffix" value=".jsp"/>
<!--这样就会自动去找 /web-inf/jsp/hello.jsp 去了-->
</bean>页面显示 404
shiro过滤器[ <!-- 11Shiro的Web过滤器 -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"/>
<property name="loginUrl" value="/login"/>
<property name="successUrl" value="/"/>
<property name="unauthorizedUrl" value="/unauthorized.jsp"/>
<!--<property name="filters">-->
<!--<util:map>-->
<!--<entry key="sysUser" value-ref="sysUserFilter"/>-->
<!--</util:map>-->
<!--</property>-->
<!--Shiro过滤链的定义-->
<!-- anon:例子/admins/**=anon 没有参数,表示可以匿名使用。-->
<property name="filterChainDefinitions">
<value>
/ui/** = anon
/user/login = anon
/login = anon
/unauthorized = anon
/** = user
</value>
</property>
</bean>
controller层
<!--配置渲染器-->
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<!--结果视图的前缀-->
<property name="prefix" value="/WEB-INF/jsp/"/>
<!--结果视图的后缀-->
<property name="suffix" value=".jsp"/>
<!--这样就会自动去找 /web-inf/jsp/hello.jsp 去了-->
</bean>页面显示 404
解决方案 »
- jasig cas提供的扩展信息,如何在spring security支持的客户端读取?
- Struts2+Freemarker批量生成html页面
- 团队开发谁来定义dao,标题要长。。。。。。。。
- 使用JBossTools 的 JBossWS 开发webservice时,工程中要添加哪些Jar包
- Hibernate抛出的Exception in thread "main" java.lang.NoSuchMethodError
- web service跨网段调用的性能问题。请有经验者指点!
- 中兴南京研究所招聘J2EE高手一名
- 请求ejb的部属问题.
- 怎样修改jtable的行间距?
- 求大神解决 getString not implemented for class oracle.jdbc.driver.T4CBlobAccessor
- 通过html页面的表单提交中文数据,Java后台出现乱码。跪求大神解答。
- 启动tomcat后,只要有数据操作mysql服务就自动关闭?
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>Archetype Created Web Application</display-name> <!--Spring 编码过滤器-->
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <!--log4j的日志配置-->
<!--<context-param>-->
<!--<param-name>log4jConfigLocation</param-name>-->
<!--<param-value>/WEB-INF/classes/log4j.properties</param-value>-->
<!--</context-param>-->
<!--<context-param>-->
<!--<param-name>log4jRefreshInterval</param-name>-->
<!--<param-value>60000</param-value>-->
<!--</context-param>-->
<!--<!– 需要添加spring-web.jar包,否则用发生错误信息 –>-->
<!--<listener>-->
<!--<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>-->
<!--</listener>--> <!--Shiro过滤器定义-->
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<!--该值缺省值为false,表示生命周期由SpringApplicationContext管理,设置为true则表示由ServletContainer管理-->
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping> <!--支持GET,PUT,POST,与Delete请求-->
<filter>
<filter-name>hiddenHttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter> <filter-mapping>
<filter-name>hiddenHttpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--加载spring容器-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/applicationContext-*</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <!--获取Request和Session-->
<!--<listener>-->
<!--<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>-->
<!--</listener>--> <servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/springMVC.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>