spring-mvc

Spring RequestBodyAdvice is not picking up by the mock MVC frame work, how ever it is working for ResponseBodyAdvice

会有一股神秘感。 提交于 2020-01-04 05:48:06
问题 We are using Spring 4.2.0-RELEASE and implementing RequestBodyAdvice and ResponseBodyAdvice advices to parse the request and response bodies. When we try to write the mock unit tests using spring test frame work, it is picking up only the Response body advice and not reuqestBodyadvice advices[0] = testRequestBodyAdvice; advices[1] = testResponseBodyAdvice; mockMvc = MockMvcBuilders.standaloneSetup(authTokenController). setControllerAdvice(advices).build(); Are we missing any thing here? 来源:

Configure Spring's MappingJacksonHttpMessageConverter

久未见 提交于 2020-01-04 05:36:18
问题 I am using MappingJacksonHttpMessageConverter in Spring MVC to automatically serialize objects like this: @RequestMapping(value="/*/getAccount", method=RequestMethod.GET) @ResponseBody public Account getAccountAction() { Account account = accountService.getAccount(); return account; } Is it possible to configure which properties of the object are serialized? In my example, Account has 3 collections as properties and serializing all these contents would result in a huge object tree. Here I

Thymeleaf fragment with own controller

元气小坏坏 提交于 2020-01-04 05:36:12
问题 I want to create a fragment with thymeleaf that has its own controller, so anytime I include the fragment, the controller is called and fills the necessary model attributes. To me this sounds like a basic request but I am new to thymeleaf and can't figure it out. So for example I have a fragment like this: <div th:fragment="table"> <tr th:each="prod : ${prods}"> <td th:text="${prod.name}"/> </tr> </div> In addition to this fragment, I would have a controller that looks somewhat like this:

Spring remoting; JdkDynamicAopProxy with no methods

删除回忆录丶 提交于 2020-01-04 05:29:20
问题 Some back story: I'm in the process of setting up a test environment of an old(er) system (2008). The system is currently in working condition, but we need to start testing it before upgrading. There is a front-end proxy application interacting through Spring (2.5.4) HTTP invoking with a back-end application. I have the source code and spring related dependencies in place, and I'm able to compile the system through build scripts shipped with the source code. I have set up a local VM acting as

Cannot send user message with Spring Websocket

匆匆过客 提交于 2020-01-04 05:28:07
问题 I read Spring docs about user destinations. I would like to use convertAndSendToUser method to send a message only to a particular user. This is the java code: @Controller public class WebsocketTest { @Autowired public SimpMessageSendingOperations messagingTemplate; @PostConstruct public void init(){ ScheduledExecutorService statusTimerExecutor=Executors.newSingleThreadScheduledExecutor(); statusTimerExecutor.scheduleAtFixedRate(new Runnable() { @Override public void run() { messagingTemplate

How to get a trivial case of Spring MVC view (JSP) resolving to work?

梦想的初衷 提交于 2020-01-04 05:26:09
问题 My app uses Spring MVC (latest; 3.2.2) to create a RESTful API returning JSON, and so far I haven't needed a view layer at all. But now, besides the API, I need a simple utility page (plain dynamic HTML) and wanted to use JSP for that. I want requests to http://localhost:8080/foo/<id> to go through a controller (Java) and end up in a JSP. Should be simple, right? But I'm getting 404; something is not right in resolving the view. HTTP ERROR 404 Problem accessing /jsp/foo.jsp. Reason: Not Found

Spring Security Login issue

三世轮回 提交于 2020-01-04 05:15:26
问题 I am new to Spring Security and have configured Spring Security in my Spring MVC application. After submission of login page, I am getting the following error The requested resource (/j_spring_security_check) is not available. I am not able to understand this behaviour. Please help. spring-security.xml <security:http auto-config="true" use-expressions="true" access-denied-page="/appln/denied"> <security:intercept-url pattern="/appln/login" access="permitAll" /> <security:intercept-url pattern

Spring Validator - show errors using <form:errors

百般思念 提交于 2020-01-04 05:03:26
问题 I am working in a spring mvc web app where i am trying to validate an db object person using Spring's Validator and trying to show the result of validator in JSP form as form:errors path="" . I have server side method in a controller as : @RequestMapping( value="/find", method = RequestMethod.GET ) public ModelAndView search(@ModelAttribute("Person") Person p,BindingResult result){ Person person2 = personDao.get( p.getId() ); ModelAndView mav = new ModelAndView("templates/person");

Spring Validator - show errors using <form:errors

橙三吉。 提交于 2020-01-04 05:03:08
问题 I am working in a spring mvc web app where i am trying to validate an db object person using Spring's Validator and trying to show the result of validator in JSP form as form:errors path="" . I have server side method in a controller as : @RequestMapping( value="/find", method = RequestMethod.GET ) public ModelAndView search(@ModelAttribute("Person") Person p,BindingResult result){ Person person2 = personDao.get( p.getId() ); ModelAndView mav = new ModelAndView("templates/person");

Spring social /connect return 404

对着背影说爱祢 提交于 2020-01-04 03:59:26
问题 I'm trying to configure spring social inside my (maven)spring MVC secured(spring security) application but when I try to access /connect/ or /connect/providerid , I always get error 404 Here is my Glassfish server log when I try to access: Info: Mapped "{[/connect/{providerId}],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.view.RedirectView org.springframework.social.connect.web.ConnectController.connect(java.lang.String