This commit is contained in:
xiangwb
2017-11-20 15:35:21 +08:00
parent 91350a2274
commit 472ccea7ee
5 changed files with 26 additions and 34 deletions
@@ -16,7 +16,6 @@ import javax.servlet.Filter;
* 作者: xiangwb
*/
@Configuration//相当于.xml文件中的<beans></beans>
//@ComponentScan(value = {"com.xwbing"}, excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, value = EnableWebMvc.class)})
//@Import(xxx.class)//用来导入其他配置类
//@ImportResource("classpath:applicationContext.xml")//用来加载其他xml配置文件
public class ApplicationContextConfig {
@@ -2,8 +2,6 @@ package com.xwbing.configuration;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import com.xwbing.handler.LoginInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
@@ -22,12 +20,9 @@ import java.util.List;
* 创建时间: 2017/5/10 16:36
* 作者: xiangwb
*/
@Configuration
@EnableWebMvc
//@ComponentScan(basePackages = {"com.xwbing.controller"}, includeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, value = RestController.class)})
@Configuration
public class DispatcherServletConfig extends WebMvcConfigurerAdapter {
private final Logger logger = LoggerFactory.getLogger(DispatcherServletConfig.class);
/***
* 添加拦截器
* @param registry
@@ -44,7 +39,9 @@ public class DispatcherServletConfig extends WebMvcConfigurerAdapter {
/**
* 配置静态访问资源
* 访问时不需要前缀
* 默认:优先级
* /**映射到
* classpath:/META-INF/resources
* classpath:/resources
* classpath:/static
@@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.List;
/**
@@ -95,16 +94,4 @@ public class TestControl {
RestMessage restMessage = qrCodeZipService.batchGetImage(response, names, fileName);
return JSONObjResult.toJSONObj(restMessage);
}
@GetMapping("test")
public JSONObject test() throws IOException {
RestMessage restMessage = new RestMessage();
String path = qrCodeZipService.getPath();
File file = new File(path + File.separator + "demo.txt");//创建文件对象,并不创建文件
if (!file.exists()) {
file.createNewFile(); //创建文件
}
return JSONObjResult.toJSONObj(restMessage);
}
}