Spring boot 学习笔记

原创
2018/12/03 09:50
阅读数 99

1、增加过滤器

1.增加Filter类,注解:

@WebFilter(filterName = "LoginFilter", urlPatterns = { "/aaa/*", "/bbb/*" })

2.Application类增加注解:

@ServletComponentScan

2、Application类注入Value

import java.io.IOException;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.stereotype.Component;

@SpringBootApplication
@ServletComponentScan
@Component
public class Application {

	private static String path;
	
	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
		
		try {
			//do something
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Value("${path}")
	public static void setPath(String path) {
		Application.path = path;
	}
	
}

 

展开阅读全文
加载中

作者的其它热门文章

打赏
0
0 收藏
分享
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部