javascript - 单击 html 链接时禁用 spring boot 请求检查

标签 javascript java spring-boot spring-security

<分区>

我在 html 页面上使用 springboot。当我单击一个链接(这只是一个重定向 href)以导航到下一页时,springboot 显示 whitelabel 错误页面。单击 href 时,Springboot 检查请求映射。我想禁用它。当我点击一个链接时,我不想让 springboot 检查请求映射。

最佳答案

路径匹配和内容协商

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.

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

关于javascript - 单击 html 链接时禁用 spring boot 请求检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58038230/

相关文章:

java - 运行 Spring Boot 命令行示例给出 `Could not find method run()`

javascript - 如何在内存中创建文件供用户下载,而不是通过服务器?

javascript - 如果没有打开相同 url 的事件选项卡,则销毁 localStorage

javascript - css 隐藏 "Choose File"按钮但在选择后显示文件

java - 限制数字输入 JTextField

java - 在 Java 中实现修改草图生成

java - 在一个 JPanel 上绘图

javascript - Webpack url-loader 中的某些图像出现 404s

spring - 测试 spring boot 1.4 应用程序时出错

java - 使用 UnicastReceivingChannelAdapter 进行 UDP 处理以创建发布-订阅 channel