servlet.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:c="http://www.springframework.org/schema/c" xmlns:cache="http://www.springframework.org/schema/cache" xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd "> <context:annotation-config /> <context:component-scan base-package="***.actions" /> <!-- <mvc:annotation-driven /> --> <!-- 映射静态资源URL --> <mvc:resources mapping="/styles/**" location="/styles/" /> <mvc:resources mapping="/scripts/**" location="/scripts/" /> <mvc:resources mapping="/resources/**" location="/resources/" /> <mvc:interceptors> <!-- 全局 拦截器/过滤器 --> <mvc:interceptor> <mvc:mapping path="/**" /> <!-- path=/** 为过滤所有请求, so 此处需要忽略掉静态资源URL --> <mvc:exclude-mapping path="/styles/**" /> <mvc:exclude-mapping path="/scripts/**" /> <mvc:exclude-mapping path="/resources/**" /> <bean class="***.adapter.PrivilegeHandlerInterceptorAdapter" /> </mvc:interceptor> <!-- 当前拦截器主要过滤静态资源,可以不要 --> <mvc:interceptor> <mvc:mapping path="/styles/**" /> <mvc:mapping path="/scripts/**" /> <mvc:mapping path="/resources/**" /> <bean class="***.adapter.ResourceHandlerInterceptorAdapter" /> </mvc:interceptor> </mvc:interceptors> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/" /> <property name="suffix" value=".jsp" /> </bean> <!-- spring4.* 和 3.* 貌似改用 RequestMappingHandlerMapping --> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"> <property name="useSuffixPatternMatch" value="false" /> <property name="useRegisteredSuffixPatternMatch" value="false" /> <property name="useTrailingSlashMatch" value="true" /> </bean> <!-- spring4.* 和 3.* 貌似改用 RequestMappingHandlerAdapter --> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> <property name="cacheSeconds" value="0" /> <property name="messageConverters"> <list> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"></bean> </list> </property> </bean> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize" value="524288000"></property> </bean> </beans>
PrivilegeHandlerInterceptorAdapter.java
/** * */ package ***.adapter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; /** * @author Colin * */ public class PrivilegeHandlerInterceptorAdapter extends HandlerInterceptorAdapter { /** * */ public PrivilegeHandlerInterceptorAdapter() { // TODO Auto-generated constructor stub } /* * (non-Javadoc) * * @see org.springframework.web.servlet.handler.HandlerInterceptorAdapter#preHandle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object) */ @Override public boolean preHandle( HttpServletRequest request, HttpServletResponse response, Object handler ) throws Exception { System.out.println( request.getRequestURI() ); System.out.println( request.getRequestURL() ); // ** 匹配到需要拦截的 URL 静态资源为 instanceof ResourceHttpRequestHandler if ( handler instanceof HandlerMethod ) { HandlerMethod method = ( HandlerMethod ) handler; String className = method.getBean().getClass().getName(); // ** Controller 的类名 String methodName = method.getMethod().getName(); // ** Controller 里执行的方法名称 } return super.preHandle( request, response, handler ); } }
context.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:c="http://www.springframework.org/schema/c" xmlns:cache="http://www.springframework.org/schema/cache" xmlns:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang" xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd "> <context:property-placeholder location="classpath:config/datasource-mysql.properties" /> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" p:driverClassName="${jdbc.driverClassName}" p:url="${mysql.url}" p:username="${mysql.username}" p:password="${mysql.password}" /> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" p:dataSource-ref="dataSource" /> <tx:annotation-driven transaction-manager="transactionManager" /> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="transactionFactory"> <bean class="org.mybatis.spring.transaction.SpringManagedTransactionFactory" /> </property> <property name="mapperLocations"> <list> <value>classpath:config/mybatis/*/Dal-*.xml</value> </list> </property> </bean> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer" p:sqlSessionFactoryBeanName="sqlSessionFactory" p:basePackage="com.defence.chat.meetya.dal" /> <!-- 应用程序包, 要扫描的根目录包名 --> <context:component-scan base-package="***"> <!-- 跳过扫描的 Controllers 所在的包 --> <context:exclude-filter type="regex" expression="***.act" /> </context:component-scan> </beans>
相关推荐
Error creating bean with name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0' defined in ServletContext resource [/WEB-INF/springMVC-servlet.xml]: Initialization of bean failed;...
org.springframework.spring-library-3.0.4.RELEASE.libd org.springframework.test-3.0.4.RELEASE.jar org.springframework.transaction-3.0.4.RELEASE.jar org.springframework.web.portlet-3.0.4.RELEASE.jar ...
8. **Java EE与微服务** - 虽然JSP和Servlet是Java EE的一部分,但现代Web开发中,它们更常用于微服务架构,与Spring Boot等框架集成,构建RESTful API。 总结,JSP-api.jar和servlet-api.jar是Java Web开发的基础...
spring-context-3.2.4.RELEASE.jar spring-core-3.2.4.RELEASE.jar spring-beans-3.2.4.RELEASE.jar spring-test-3.2.4.RELEASE.jar spring-web-3.2.4.RELEASE.jar spring-aop-3.2.4.RELEASE.jar spring-webmvc-...
org.springframework.web.servlet-3.0.0.M4.jar
包含spring 3.0.5的所有jar文件: org.springframework.aop-3.0.5.RELEASE.jar org.springframework.asm-3.0.5...org.springframework.web.servlet-3.0.5.RELEASE.jar org.springframework.web.struts-3.0.5.RELEASE.jar
spring-framework-3.0.5.RELEASE-dependencies 好不容易找到了,赶紧分享一下 因为不能大于20M,共分了8个包,都是独立的,我列了目录,可以只下载需要的包,这是1号包: 1号包: edu.emory.mathcs.backport edu.oswego.cs....
例如,`spring-aop.jar`包含AOP(面向切面编程)支持,`spring-beans.jar`包含了bean容器和依赖注入的核心功能,而`spring-context.jar`提供了上下文支持,包括事件传播、国际化和资源访问等。理解这些库的功能有助...
`spring-beans`的配置文件通常以`.xsd`为后缀,这些文件定义了XML Schema,用于验证Spring配置文件的语法和结构。本文将深入探讨`spring-beans-3.0.xsd`和`spring-beans-3.1.xsd`这两个版本的变更,以及它们在Spring...
aopalliance-1.0.jar,org.springframework.aop-3.0.0.RELEASE.jar,org.springframework.jdbc-3.0.0.RELEASEorg.springframework.beans-3.0.0.RELEASE.jar等
Servlet-api.jar是Java Web开发中不可或缺的一个库文件,它包含了Servlet和JSP(JavaServer Pages)规范的API接口。这个库文件主要用于与Web服务器交互,处理HTTP请求,并生成响应。在本文中,我们将深入探讨Servlet...
org.springframework.spring-library-3.1.RELEASE.libd org.springframework.test-3.1.RELEASE.jar org.springframework.transaction-3.1.RELEASE.jar org.springframework.web.portlet-3.1.RELEASE.jar org....
spring-framework-4.2.0.RELEASE-dist.zip spirng 最新 完整包 包含源码 更新时间:2015-8-10 22:33:31 同时更新的还有: 最新struts2: 最新hibernate:http://download.csdn.net/detail/angel_he/8987791
spring-context-support.jar spring整合任务调度quartz必需jar 还需要quartz-all-x.x.x.jar quartz版本必需在1.8.x以下
这两个模块的 jar 文件,`spring-data-commons-1.7.2.RELEASE.jar` 和 `spring-data-jpa-1.5.2.RELEASE.jar`,包含了它们各自的功能实现和依赖。在实际项目中,将这些 jar 文件添加到类路径,就可以利用 Spring Data...
Spring Framework 是一个开源的应用程序框架,主要针对Java平台,它为构建企业级应用程序提供了全面的基础设施。Spring的核心特性包括依赖注入、面向切面编程(AOP)、模型-视图-控制器(MVC)架构模式以及对Java EE...
在给定的标题和描述中,提到了一系列重要的JAR包,这些包在处理XML、JavaServer Faces(JSF)以及Servlet相关的开发时扮演着关键角色。让我们逐一了解这些JAR包的功能和相关知识点。 1. **jdom.jar**:Java ...
【标题】"jersey-container-servlet-2.0-m04.zip" 提供的是 Jersey 2.0 版本的Servlet容器模块,这是一个用于构建RESTful Web服务的Java框架。Jersey是JAX-RS(Java API for RESTful Web Services)规范的参考实现,...
4. **`@WebServlet`注解**:在Servlet 3.0及以上版本中,可以用注解直接定义Servlet,无需在部署描述符(web.xml)中配置。 5. **`doGet`和`doPost`方法**:处理HTTP GET和POST请求的主要方法,通过`...
Classes contained in spring-mock.jar: org.springframework.mock.jndi.ExpectedLookupTemplate.class org.springframework.mock.jndi.SimpleNamingContext.class org.springframework.mock.jndi....