SpringMvc - small tips for filters

In the original Spring-Mvc, the DELETE and PUT-HTTP methods cannot be parsed by default. We need to configure the filter using two methods, and perform data interception and filtering on the request to get the results we want.

DELETE method:
Add a filter to the web.xml file to filter the DELETE request.
!--Use to filter the delete request-->


By setting the filter and the filter mapping path, filter the request

The DELETE method can be used by setting the _method method in the corresponding JSP page

put method:
If you want to use a custom view parser in web.xml, you need to set and load your own parser in the path. In spring's listener listener, if the name is not set, the default name will be contextConfigLocaiton, and the path value will be / root-context.xml

Only the KEY value placed in the root-context.xml file will be parsed by the Spring framework, because to make our own Spring-web.xml take effect, the DispatchServlet is required to load our data, and the filtering action is when the request reaches the DispatchServlet Before, so if we want to use the view parser in the spring-web.xml file to perform our usual view parsing at this time, it is impossible.

In the spring root context, we only need to configure our own parser in the spring-root context, and it will take effect.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325114849&siteId=291194637