spring-mvc

Spring Stomp CAN send unsolicited messages

不羁的心 提交于 2020-01-15 06:21:12
问题 In the Spring WebSocket docs I found this sentence: It is important to know that a server cannot send unsolicited messages. http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html (25.4.1) However I tried this code: @Controller public class WebsocketTest { @Autowired public SimpMessageSendingOperations messagingTemplate; @PostConstruct public void init(){ ScheduledExecutorService statusTimerExecutor=Executors.newSingleThreadScheduledExecutor();

Spring Stomp CAN send unsolicited messages

天涯浪子 提交于 2020-01-15 06:19:35
问题 In the Spring WebSocket docs I found this sentence: It is important to know that a server cannot send unsolicited messages. http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html (25.4.1) However I tried this code: @Controller public class WebsocketTest { @Autowired public SimpMessageSendingOperations messagingTemplate; @PostConstruct public void init(){ ScheduledExecutorService statusTimerExecutor=Executors.newSingleThreadScheduledExecutor();

javax validation on nested object with groups

為{幸葍}努か 提交于 2020-01-15 05:55:29
问题 Here is my java code class AbstractO{ public interface Save{}; // for groups public interface Update{}; // for groups } class A extends AbstractO{ public Integer id; @NotNull(groups={A.Save.class}) @Valid public B b; } class B extends AbstractO{ @NotNull(groups={B.Update.class}) public Integer id; @NotNull(groups={A.Save.class}) public Integer prop } // controller method @ResponseBody public ResponseEntity<A> save(@RequestBody @Validated(value = { A.Save.class }) A , BindingResult

Component controller in Spring-MVC

走远了吗. 提交于 2020-01-15 03:55:51
问题 I am designing a web application that requires loading multiple components on a single page. (In terms of page layout is similar to Google reader) I like to keep these components separate from each other (for reasons such as reusability). For example, I have a left panel that let's user navigate among multiple feeds that he's subscribed to (user specific) and on the right side of that we show the contents of that feed, and maybe a right panel which shows some specific info about that specific

Spring Security 3.1.3 @EnableWebSecurity

南楼画角 提交于 2020-01-15 03:39:22
问题 I'm having trouble finding which package contains @EnableWebSecurity in Spring Security 3.1.3. I've added core, config, web and ldap security packages, but the annotation remains unavailable. Has it been replaced by another annotation? 回答1: I think java config support is not yet released with Spring Security, but available as a separate module in spring-security-javaconfig. See instructions in the linked page about how to include the jar into your maven build. 回答2: I faced the same problem

Get server name from PostConstruct method in a Spring controller

六眼飞鱼酱① 提交于 2020-01-15 03:22:08
问题 If I had an instance of HttpServletRequest , I could do request.getServerName() to get the server name. However, during the post initialization of the controller beans, I have no instance of HttpServletRequest . @Controller @RequestMapping(value = {"/data"}) public class DataController { @PostConstruct public void init() { // how to get server name? } } How do I get the server name in this case? 回答1: There are no good ways to do it. Generally speaking, server doesn't know the name that can be

When Spring Boot application running by Intelij Idea views can`t be resolved

為{幸葍}努か 提交于 2020-01-15 03:21:28
问题 I have encountered a strange situation, the decision which I cant find. I`m runnig simple demo application using Spring Boot 1.3.0 and Intelij Idea 14.1.3 The problem is that Spring MVC cant resolve the view: javax.servlet.ServletException: Could not resolve view with name 'home' in servlet with name 'dispatcherServlet' Oddity is that when I run application by Maven Spring Boot-plugin mvn clean spring-boot:run everythig works fine. Both views ("home.jsp" - returning from Controller and "start

Spring MVC. Default values for fields of method parameter

六眼飞鱼酱① 提交于 2020-01-15 02:48:28
问题 I have a simple controller with method test: @RequestMapping(produces = "application/json") @ResponseBody public HttpEntity<Void> test(Test test) { return new ResponseEntity<>(HttpStatus.OK); } Test class looks like this: public class Test { private String name; private Date date; public String getName() { return name; } public void setName(String name) { this.name = name; } public Date getDate() { return date; } @DateTimeFormat(iso= DateTimeFormat.ISO.DATE) public void setDate(Date date) {

Spring MVC. Default values for fields of method parameter

帅比萌擦擦* 提交于 2020-01-15 02:46:52
问题 I have a simple controller with method test: @RequestMapping(produces = "application/json") @ResponseBody public HttpEntity<Void> test(Test test) { return new ResponseEntity<>(HttpStatus.OK); } Test class looks like this: public class Test { private String name; private Date date; public String getName() { return name; } public void setName(String name) { this.name = name; } public Date getDate() { return date; } @DateTimeFormat(iso= DateTimeFormat.ISO.DATE) public void setDate(Date date) {

Function isAssignableFrom returns false during server startup

ぐ巨炮叔叔 提交于 2020-01-14 14:44:49
问题 Implementing an oauth2 system, I am having some problems with the following code: import org.springframework.security.oauth2.provider.endpoint.FrameworkEndpointHandlerMapping; import org.springframework.web.servlet.HandlerMapping; ... HandlerMapping.class.isAssignableFrom(FrameworkEndpointHandlerMapping.class); Indeed, as the class FrameworkEndpointHandlerMapping is implementing the interface HandlerMapping , this function should always return true . It is the case when I run a unit test on