Created
July 13, 2025 18:14
-
-
Save arleighdickerson/f8b1d16c657d0973382b8add6ce0fd5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lombok.val; | |
import org.springframework.stereotype.Component; | |
import org.springframework.web.filter.OncePerRequestFilter; | |
import javax.servlet.FilterChain; | |
import javax.servlet.ServletException; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
import java.io.IOException; | |
@Component | |
class IndexDotHtmlFilter extends OncePerRequestFilter { | |
@Override | |
protected void doFilterInternal( | |
HttpServletRequest request, | |
HttpServletResponse response, | |
FilterChain filterChain | |
) throws ServletException, IOException { | |
val path = request.getRequestURI().substring(request.getContextPath().length()); | |
if ( | |
!path.startsWith("/api") && | |
!path.startsWith("/wss") && | |
!path.startsWith("/ctl") && | |
!path.contains(".") && | |
path.matches("/(.*)") | |
) { | |
request.getRequestDispatcher("/index.html").forward(request, response); | |
} else { | |
filterChain.doFilter(request, response); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment