有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

javascript在单击html链接时禁用springboot请求检查

我正在使用springboot和html页面。当我点击一个链接(这只是一个重定向a href)导航到下一页时,springboot会显示白色标签错误页面。Springboot在我点击a href时检查请求映射。我想禁用这个。当我点击一个链接时,我不希望springboot检查请求映射


共 (1) 个答案

  1. # 1 楼答案

    路径匹配和内容协商

    Spring MVC can map incoming HTTP requests to handlers by looking at the request path and matching it to the mappings defined in your application (for example, @GetMapping annotations on Controller methods).

    By default, Spring Boot serves static content from a directory called /static (or /public or /resources or /META-INF/resources) in the classpath or from the root of the ServletContext. It uses the ResourceHttpRequestHandler from Spring MVC so that you can modify that behavior by adding your own WebMvcConfigurer and overriding the addResourceHandlers method.

    In a stand-alone web application, the default servlet from the container is also enabled and acts as a fallback, serving content from the root of the ServletContext if Spring decides not to handle it. Most of the time, this does not happen (unless you modify the default MVC configuration), because Spring can always handle requests through the DispatcherServlet.

    您必须定义回退方法的行为