设置web.xml使用基于java的配置
来源:互联网 发布:sql sum函数分组求和 编辑:程序博客网 时间:2024/06/01 08:55
web.xml
添加contextClass参数,改写contextConfigLocation的值,为javaconfig的全名
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" ><web-app> <display-name>Archetype Created Web Application</display-name> <context-param> <param-name>contextClass</param-name> <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value> </context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value>config.ViewConfig</param-value> </context-param> <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> </filter> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextClass</param-name> <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value> </init-param> <init-param> <param-name>contextConfigLocation</param-name> <param-value>config.DispacheServletConfig</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/page/*</url-pattern> </servlet-mapping></web-app>
config.ViewConfig.class
package config;import org.springframework.context.annotation.Configuration;import org.springframework.context.annotation.ImportResource;/** * Created by Administrator on 2017/5/27. */@Configuration@ImportResource("classpath:applicationContext.xml")public class ViewConfig {}
config.DispacheServletConfig.class
package config;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.context.annotation.ImportResource;import org.springframework.web.multipart.MultipartResolver;import org.springframework.web.multipart.support.StandardServletMultipartResolver;/** * Created by Administrator on 2017/6/1. */@Configuration@ImportResource("classpath:dispatcher-servlet.xml")public class DispacheServletConfig { @Bean public MultipartResolver multipartResolver(){ return new StandardServletMultipartResolver(); }}
阅读全文
0 0
- 设置web.xml使用基于java的配置
- Spring web基于javaconfig类配置 的web.XML配置
- java Web.xml的配置
- java web开发中web.xml配置(仅基于servlet的)
- web.xml配置,基于SpringMVC
- JAVA WEB开发之基于xml配置文件的分页实现(一) 分页配置原理
- java中web.xml的配置
- 基于S2SH框架的项目—web.xml文件配置
- Spring Web MVC简介 、基于XML配置的MVC应用 、基于注解配置的MVC应用
- 使用 spring web 时候 web.xml 的配置
- 使用 spring web 时候 web.xml 的配置
- Java web项目中web.xml的配置
- java创建的web工程中web.xml配置说明
- Java web项目中web.xml的配置
- java web 之 不同版本的web.xml配置
- 利用Java技术实现基于XML的Web服务
- Web.Xml的配置
- web.xml的配置
- 单词切分
- 套接字的select、WsaAsyncSelect、WsaEventSelect模型
- How To Configure VMware fencing using fence
- Redis主从复制和集群配置
- spring boot 上传文件过大失败
- 设置web.xml使用基于java的配置
- 用反射机制读出类中的信息
- 2017年第0届浙江工业大学之江学院程序设计竞赛决赛—B
- Laravel建立项目
- HTTP协议
- web前端之闭包
- tpyboad开发板之主要函数
- SpringMVC在使用JSON时出现Error: Content type 'application/json;charset=UTF-8' not supported
- C程序设计进阶week2