Filter interception problem

       I learned the knowledge of Filter today. I first read the blog, and then I found that I didn’t understand it very well, so I watched the previous set of videos and followed it. I found one thing, that they are all the same, maybe they learned They are all relatively deep or taught by teachers. In fact, it is still very hard for beginners and self-learners to learn. Next, I will summarize the problems I encountered and how I solved them.

       Now many Filter filters on Baidu simply build a filter and start explaining its operation principle. The last sentence is very simple. In fact, the reason why we learn filters is to make our products better:

1. The function of the filter is to block our request for the page, and make judgment and release. We cannot directly use the link to access the page blocked by us (many people may have such doubts, that is, we put it in the WEB- INF directory is not enough, but you can try, the jsp in the WEB-INF directory is also linked, about Servlet, you can directly access, so Filter filter has a good protection effect, in login)

2. Set up the interception of the filter. At the beginning, I used "/*" to intercept everything, but I encountered a lot of problems. First of all, the page has no style, and after entering the page, all the buttons have no effect, which will be very embarrassing. , we will be stunned all of a sudden, I feel that the filter is very difficult, in fact, it is not because our interception is in addition to the problem, there is no style, because we have intercepted both css and js, the button has no effect, because The Servlet is intercepted, so when we set up the interception, we can set up multiple interceptions, not only one, but for the sake of convenience, we can divide these jsp pages into different packages, and directly intercept them at the end The package is just fine.

3. The setting of the interception path, the path we write is the path we do not want to be able to access directly, not the page that sends the request.

        This is the small three points I have gained today, I will continue to learn and supplement, and the listener will make an appointment tomorrow.

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326609858&siteId=291194637