Java – returns a static HTML without redirection in spring
                                        
                    •
                    Java                                    
                So I want to return to the HTML page without sending a redirect The reason is that the URL in the browser is changed by redirection. If they don't log in, I can't redirect someone to log in What is the most direct way? It seems that it should be simple without using JSP or other server - side view technologies
Solution
You can use a striker
Example:
Say / static / mywebpage Html is your static HTML page
This code will return mywebpage HTML without changing the URL
@Controller
@RequestMapping("/path")
public class TestingController {
    @RequestMapping("/page")
    public String someOtherPage(HttpServletRequest request,HttpServletResponse response) {
        return "forward:/static/myWebpage.html";
    }
}
Your web address will be "localhost / path / page", but you will see "localhost / static / mywebpage. HTML"
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        