227得票7回答
@GetMapping和@RequestMapping(method = RequestMethod.GET)注解之间的区别

@GetMapping和@RequestMapping(method = RequestMethod.GET)之间有什么区别?我在一些Spring Reactive示例中看到,使用@GetMapping代替@RequestMapping。

219得票4回答
在Spring RESTful应用中,何时使用ResponseEntity<T>和@RestController?

我正在使用Spring Framework 4.0.7,结合MVC和Rest进行工作。 我可以与以下内容和谐地工作: @Controller ResponseEntity&lt;T&gt; 例如:@Controller @RequestMapping("/person") @Prof...

82得票8回答
为[class org.springframework.web.bind.MethodArgumentNotValidException]映射了模糊的@ExceptionHandler方法

我想使用 @ControllerAdvice 处理 MethodArgumentNotValidException 异常,代码如下:@ControllerAdvice public class RestResponseEntityExceptionHandler extends Respons...

61得票8回答
如何使用@ResponseBody从Spring Controller返回JSON数据

Spring版本为4.2.0,Hibernate版本为4.1.4 以下是我的Controller函数:@RequestMapping(value = "/mobile/getcomp", method = RequestMethod.GET) @ResponseBody public List...

56得票2回答
何时使用AbstractAnnotationConfigDispatcherServletInitializer和WebApplicationInitializer?

我正在使用Spring 4.0.7。我研究了如何通过JavaConfig配置Spring MVC。实际上,直到昨天,我看到了两种使用以下两个选项的配置: 1. 扩展AbstractAnnotationConfigDispatcherServletInitializer。 2. 扩展WebMvc...

51得票2回答
@EntityScan和@ComponentScan之间的区别

我正在尝试理解这里的区别。我看到一个类已经用同一个包示例注释了它们两个: @Configuration @EntityScan("some.known.persistence") @ComponentScan({ "some.known.persistence"}) public class...

42得票2回答
在Tomcat 6中部署Spring 4.0时出现了AbstractMethodError错误。

我在将Spring 4.0.1应用程序部署到Tomcat 6.0.37时遇到了以下异常:SEVERE: Exception sending context initialized event to listener instance of class org.springframework.w...

41得票1回答
使用Sockjs和Spring 4的WebSocket,但不使用Stomp

有没有一种方法可以在不使用STOMP的情况下,使用SockJS客户端和Spring 4服务器来使用WebSockets? 根据Spring网站上的这个教程,我知道如何使用Stomp和Spring 4设置基于WebSocket的应用程序。在客户端方面,我们有: var socket =...

41得票3回答
多种情景下的 @RequestMapping 生成 JSON/XML 结合 Accept 或 ResponseEntity

我正在使用Spring 4.0.7。关于Spring MVC,出于研究目的,我拥有以下内容:@RequestMapping(value="/getjsonperson", method=RequestMethod.GET, p...

41得票2回答
如何在Spring MVC中使用JasperReports?

我一直在研究如何使用JasperReports(6.0.0)和Spring MVC(4.1.3)生成PDF报告。Spring提供了许多“Spring特定”的集成方式,用于生成PDF报告: 使用JasperReportsPdfView依赖于现已弃用的JasperReport功能 使用Jasp...