1. Java Code
Public classMyfilterImplementsHandlerinterceptor {/*** Execute after generating view*/ Public voidaftercompletion (httpservletrequest request, httpservletresponse response, Object obj, Exception e) throwsException {System.out.println ("View has been generated ... "); } /*** After the action interaction, block the view before generating the*/ Public voidPosthandle (httpservletrequest request, httpservletresponse response, Object obj, Modelandview mav)throwsException {System.out.println ("After the action interaction, before generating the view ... "); } /*** intercept before action interaction*/ Public BooleanPrehandle (httpservletrequest request, httpservletresponse response, Object obj)throwsException {System.out.println ("Action interaction before blocking ... "); return true; }}
2. springmvc-servlet.xml file
<!---<mvc:interceptors> < class = "Com.erim.web.common.MyFilter" /> </ mvc:interceptors >
How to use the SPRINGMVC interceptor