spring-mvc 相关问题

基于模型 - 视图 - 控制器(MVC)模式构建Java Web应用程序的框架。它从底层视图技术中提升灵活和分离的代码。

在 Citrix 机器中运行时,Spring Boot 端口随机打开

我有一台 Citrix 机器,我必须在那里运行一个 Web 服务(使用 Spring Boot 开发)。它是 Windows 10 主机。有一个奇怪的行为 - 端口是随机选择的而不是配置...

回答 2 投票 0

Spring @DateTimeFormat 读取 POST 参数时出现异常

我将日期“Apr 15, 2024, 12:00:21 PM”作为 POST 参数发送。我试图将其读入 Spring MVC @RequestMapping 方法,如下所示: 公共空间

回答 1 投票 0

Spring 应用程序未正确扫描 Bean

我正在为一个业余项目创建一个小型 Spring 应用程序来练习 Spring,并且不断遇到同样的问题:我认为它没有正确扫描我的组件/bean。 我运行

回答 1 投票 0

尽管正确提供了角色,Spring 安全授权仍无法正常工作

http.authorizeRequests().antMatchers("/dms**").access("hasAnyRole('admin','dms')"); 用户应具有 admin 或 dms 角色才能导航到该页面。 我以管理员身份登录。 从日志中我可以...

回答 2 投票 0

Spring Boot找不到jsp文件

我正在开发简单的 Spring Boot MVC 应用程序。以前我只使用 Spring + Hibernate(即有 servlet.xml 等)来完成所有工作,并且我正在尝试重建项目以使用 Spr...

回答 2 投票 0

使用 Spring HATEOAS 时在链接中包含 @ModelAttribute

我正在使用 Spring HATEOAS 提供的工具构建控制器方法的 url。我现在看到的问题是,当我使用@ModelAttr时,我无法生成带有必要请求参数的链接...

回答 1 投票 0

Spring:@ModelAttribute VS @RequestBody

如有错误请指正。 两者都可用于数据绑定。 问题是什么时候使用@ModelAttribute? @RequestMapping(value="/owners/{ownerId}/pets/{petId}/edit", method = RequestMetho...

回答 10 投票 0

学习Spring的@RequestBody和@RequestParam注解

我正在编辑一个使用Spring的Web项目,我需要添加一些Spring的注释。我添加的其中两个是@RequestBody 和@RequestParam。我查了一下发现......

回答 2 投票 0

学习Spring的@RequestBody和@RequestParam

我正在编辑一个使用Spring的Web项目,我需要添加一些Spring的注释。我添加的其中两个是@RequestBody 和@RequestParam。 我查了一下发现......

回答 2 投票 0

CVE-2022-22965 - Tomcat 特定

我正在尝试理解 Spring 发布的问题描述和解决方案 https://spring.io/blog/2022/03/31/spring-framework-rce-early-announcement 然而,我不明白...

回答 1 投票 0

springBoot + Thymeleaf:设置区域设置

我的配置运行良好: @配置 @EnableWebSecurity @EnableMethodSecurity(securedEnabled = true, jsr250Enabled = true) 公共类 MvcConfig 实现 WebMvcConfigur...

回答 1 投票 0

将 Spring MVC 投影与 JSON 和 Jackson 结合使用

在新版本的 Spring Data (Fowler) 中,可以将一个接口传递给 Spring MVC 控制器操作,然后 Spring Data 将自动创建一个代理实现并将值绑定到此...

回答 1 投票 0

com.example.demo.services.StudentServiceImpl 需要类型为“com.example.demo.repositories.StudentRepository”的 bean 无法解决

我收到一条错误消息“描述: com.example.demo.services.StudentServiceImpl 中构造函数的参数 0 需要一个类型为“com.example.demo.repositories.StudentRepository”的 bean,该 bean 与...

回答 1 投票 0

如何通过URL在源码中找到Spring映射的方法?

我正在调试一个项目,一个网上银行网站后端,使用Spring。通常,我必须在错误报告中锁定的是单击哪些按钮来重现错误。在浏览器开发环境中...

回答 3 投票 0

com.pzh.code.chion.service.impl.db1.UserServiceImpl 中构造函数的参数 0 需要类型为 的 bean

说明: com.pzh.code.chion.service.impl.db1.UserServiceImpl 中构造函数的参数 0 需要类型为“com.pzh.code.chion.repository.db1.UserRepository”的 bean,但无法找到。 空调...

回答 1 投票 0

springBoot + Thymeleaf:包含片段

我有这个片段: 我有这个片段: <!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <head th:fragment="common-header-imports"> <meta charset="utf-8"> <meta content="width=device-width, initial-scale=1.0" name="viewport" <!-- Other meta tags --> <meta content="" name="ZRTHEMES"/> <!-- Google Fonts --> <link href="https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,600;1,700&amp;family=Montserrat:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&amp;family=Raleway:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&amp;display=swap" rel="stylesheet"> <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin=""> <link href="https://fonts.googleapis.com/css2?family=Oswald:wght@500&amp;display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400&amp;display=swap" rel="stylesheet"> <!-- Vendor CSS Files --> <link href="assets/vendor/aos/aos.css" rel="stylesheet"> <link href="assets/stylesheets/font-awesome.min.css" rel="stylesheet"> <link href="assets/vendor/swiper/swiper-bundle.min.css" rel="stylesheet"> <link href="assets/vendor/glightbox/css/glightbox.min.css" rel="stylesheet"> <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet"> <!-- Main CSS File --> <link href="assets/stylesheets/styles.css" rel="stylesheet"> <link rel="stylesheet" th:href="@{/css/style-links.css}"/> <link rel="stylesheet" th:href="@{/css/responsive.css}"/> </head> </html> 还有这个: <!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <header th:fragment="common-header" id="header" class="header d-flex align-items-center sticked stikcy-menu"> <div class="container-fluid container-xl d-flex align-items-center justify-content-between"> <a href="index.html" class="logo d-flex align-items-center"> <img src="assets/images/logo.png" alt="logo"> </a> <nav id="navbar" class="navbar"> <ul> <li><a href="/" class="">Home</a></li> <!--li><a href="services.html" class="">Services</a></li> <li><a href="portfolio.html" class="">Portfolio</a></li> <li><a href="testimonials.html" class="">Testimonials</a></li> <li><a href="team.html" class="">Team</a></li> <li class="dropdown"><a href="#"><span>Menu</span> <i class="bi bi-chevron-down dropdown-indicator"></i></a> <ul> <li><a href="about.html">About</a></li> <li><a href="packages.html">Pricing</a></li> <li><a href="faqs.html">FAQs</a></li> <li><a href="privacy-policy.html">Terms &amp; Conditions</a></li> <li><a href="privacy-policy.html">Privacy Policy</a></li> <li><a href="blogs.html">Blogs</a></li> <li><a href="blog-details.html">Blog Detail Page</a></li> </ul> </li--> <li><a href="/blogs">News</a></li> </ul> </nav><!-- .navbar --> <!--a href="contact.html" class="btn-get-started hide-on-mobile">Get Quotes</a--> <button id="darkmode-button"><i class="bi bi-moon-fill"></i></button> <i class="mobile-nav-toggle mobile-nav-show bi bi-list"></i> <i class="mobile-nav-toggle mobile-nav-hide d-none bi bi-x"></i> </div> </header> </html> 还有这个: <!DOCTYPE html> <html lang="zxx"> <head th:replace="~{common/headerImports :: common-header-imports}"> <title>title</title> </head> <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-RZXQZB1MDJ"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-RWXQZB9MDJ'); </script> <body> <header th:replace="~{common/header :: common-header}"> .... </html> 但我只看到一个白色页面,没有加载任何内容 每当您遇到此类问题时,从浏览器检查页面源并查看实际生成的内容以及请求的响应以查看从服务器接收到的内容非常有意义。 确保您的脚本位于 head 或 body 内,因此移动此: <!-- Google tag (gtag.js) --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-RZXQZB1MDJ"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-RWXQZB9MDJ'); </script> 进入 Google 指示您移动的位置,大概位于 head 标签的末尾(在其内部)。根据您共享的内容,您似乎已将 html 嵌入到另一个 html 中,并且您已将内容放在 head 和 body 之外。解决这些问题。 此外,很可能发生了一些服务器端错误,因此您需要检查请求的状态以及可能的服务器日志。您也可以检查客户端控制台是否存在客户端问题。 并确保正确嵌入片段。 如果以上所有内容都经过仔细检查并修复,那么它应该可以工作。

回答 1 投票 0

@EnableAutoConfiguration 不适用于@WebMvcTest。为什么?

我发现使用@WebMvcTest时必须手动@Import自动配置类 我在下面的 MRE 中使用了 Spring Cloud Gateway MVC,因此需要额外的 @Imports。如果我用普通的

回答 1 投票 0

com.example.demo.services.StudentServiceImpl 中构造函数的参数 0 需要类型为“com.example.demo.repositories.StudentRepository”的 bean

我尝试运行 Spring Boot 但最终显示错误: 描述: com.example.demo.controller.StudentController 中构造函数的参数 0 需要类型为“com.example.demo.

回答 1 投票 0

在 Spring 应用程序 RestController 响应中将所有空字符串值写入为空字符串

我有一个带有 React 前端的 Spring 应用程序。前端希望将空字符串值表示为“”而不是null。有没有办法做到这一点而不必注释每个...

回答 1 投票 0

如何在后端 Spring boot 中获取 URL Frontend?

例如:我位于 URL http://localhost:3000/admin/posts (前端)并将请求发送到 URL http://localhost:8080/test/user (后端)。当我在后端时如何获取 URL 前端?

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.