Package ru.vyarus.guicey.spa.filter
Class SpaRoutingFilter
- java.lang.Object
-
- ru.vyarus.guicey.spa.filter.SpaRoutingFilter
-
- All Implemented Interfaces:
jakarta.servlet.Filter
public class SpaRoutingFilter extends java.lang.Object implements jakarta.servlet.FilterFilter must be mapped to assets servlet, serving spa application. Bypass all calls to servlet, but if servlet returns 404, tries to redirect to application main page.This is important to properly handle html5 client routing (without hashbang).
In order to route, filter checks request accept header: if it's compatible with "text/html" - routing is performed. If not, 404 error sent. Also, regex pattern is used to prevent routing (for example, for html templates). This is important for all other assets, which absence must be indicated.
- Since:
- 02.04.2017
-
-
Constructor Summary
Constructors Constructor Description SpaRoutingFilter(java.lang.String target, java.lang.String noRedirectRegex)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()voiddoFilter(jakarta.servlet.ServletRequest servletRequest, jakarta.servlet.ServletResponse servletResponse, jakarta.servlet.FilterChain chain)voidinit(jakarta.servlet.FilterConfig filterConfig)
-
-
-
Method Detail
-
init
public void init(jakarta.servlet.FilterConfig filterConfig) throws jakarta.servlet.ServletException- Specified by:
initin interfacejakarta.servlet.Filter- Throws:
jakarta.servlet.ServletException
-
doFilter
public void doFilter(jakarta.servlet.ServletRequest servletRequest, jakarta.servlet.ServletResponse servletResponse, jakarta.servlet.FilterChain chain) throws java.io.IOException, jakarta.servlet.ServletException- Specified by:
doFilterin interfacejakarta.servlet.Filter- Throws:
java.io.IOExceptionjakarta.servlet.ServletException
-
destroy
public void destroy()
- Specified by:
destroyin interfacejakarta.servlet.Filter
-
-