网友回复
1、首先在application类中增加注解ServletComponentScan,代码如下:
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; @SpringBootApplication @ServletComponentScan public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }2、新增一个MyFilter的类
import jakarta.servlet.*; import jakarta.servlet.annotation.WebFilter; import jakarta.servlet.http.HttpServletRequest; import org.springframework.core.annotation.Order; import java.io.IOException; @WebFilter(urlPatterns = "/test/*", ...
点击查看剩余70%