spring-mvc

Reflectively getting list of Spring MVC controllers matching specific url

自古美人都是妖i 提交于 2020-01-22 05:58:40
问题 How to reflectively get list of all controllers (best if not only annotated, but also specified in xml), matching some specfic url in your Spring MVC application? In case of annotated-only, @Autowired private ListableBeanFactory listableBeanFactory; ... whatever() { Map<String,Object> beans = listableBeanFactory.getBeansWithAnnotation(RequestMapping.class); // iterate beans and compare RequestMapping.value() annotation parameters // to produce list of matching controllers } could be used, but

Spring MVC controller Test - print the result JSON String

前提是你 提交于 2020-01-22 04:18:49
问题 Hi I have a Spring mvc controller @RequestMapping(value = "/jobsdetails/{userId}", method = RequestMethod.GET) @ResponseBody public List<Jobs> jobsDetails(@PathVariable Integer userId,HttpServletResponse response) throws IOException { try { Map<String, Object> queryParams=new LinkedHashMap<String, Object>(); queryParams.put("userId", userId); jobs=jobsService.findByNamedQuery("findJobsByUserId", queryParams); } catch(Exception e) { logger.debug(e.getMessage()); response.sendError

Spring Portlet Jquery Ajax post to Controller

旧城冷巷雨未停 提交于 2020-01-22 02:34:18
问题 EDIT: The startdate and enddate are joda dateTime in the POJO and the error I get is: SystemOut O 14:10:16.040 [WebContainer : 2] DEBUG org.springframework.beans.BeanUtils - No property editor [org.joda.time.DateTimeEditor] found for type org.joda.time.DateTime according to 'Editor' suffix convention ... SystemOut O Error::Failed to convert property value of type 'java.lang.String' to required type 'org.joda.time.DateTime' for property 'startTimestamp'; nested exception is java.lang

spring hibernate.cfg.xml not found

走远了吗. 提交于 2020-01-22 02:17:15
问题 Configuration configuration = new Configuration().configure("hibernate.cfg.xml"); My configuration file in src/. still i got this error. can some one spot my mistake. 回答1: You're using maven with the standard directory layout, so it'll compile the stuff it finds under src/main/java , and copy the stuff it finds under src/main/resources . Your config file is not in any type of source , resource , or test path. It's close, but it's not in any of them, and it needs to be for maven to do

Why does this code generate the error “The end tag ”</c:when“ is unbalanced”?

梦想与她 提交于 2020-01-21 11:33:47
问题 I don't understand why I get the error: The end tag "</c:when" is unbalanced when this code is run: <c:choose> <c:when test="${label == 'Apple'}"> <form:form modelAttribute="fruit" action="/fruit/${fruitId}" method="post"> <form:input path="fruitId" type="hidden" value="${fruitId}"/> </c:when> <c:when test="${label == 'Orange'}"> <form:form modelAttribute="fruit" action="/fruit/${fruitId}" method="post"> <form:input path="fruitId" type="hidden" value="${fruitId}"/> </c:when> </c:choose> 回答1:

@ModelAttribute and abstract class

☆樱花仙子☆ 提交于 2020-01-21 10:13:53
问题 I know that there have been similar questions. The examples given in them are too fragmentary and unclear. I need to edit the entities through a form on the page that sends the POST. The standard method is a method in the controller uses the parameter with @ModelAttribute and validator. If one form serves some subclass of an abstract class, there are no problems with the generation of the necessary fields, but there is a problem in the controller. As I understand it, @ModelAttribute works

@ModelAttribute and abstract class

送分小仙女□ 提交于 2020-01-21 10:09:35
问题 I know that there have been similar questions. The examples given in them are too fragmentary and unclear. I need to edit the entities through a form on the page that sends the POST. The standard method is a method in the controller uses the parameter with @ModelAttribute and validator. If one form serves some subclass of an abstract class, there are no problems with the generation of the necessary fields, but there is a problem in the controller. As I understand it, @ModelAttribute works

Why I can't handle multipart upload in this Spring Boot application? I obtain “no matching editors or conversion strategy found”

不问归期 提交于 2020-01-21 07:24:08
问题 I am working on a Spring Boot application and I am finding some difficulties trying to implement a controller method that handle the multipart file upload . To do it I have adapted this Spring MVC tutorial: http://www.codejava.net/coding/upload-files-to-database-with-spring-mvc-and-hibernate Basically to add the multipart support to my Spring Boot project I have not added this bean in a configuration class (as done in the tutorial): @Bean(name = "multipartResolver") public

How to handle RESTful delete in Spring MVC

拟墨画扇 提交于 2020-01-21 01:42:46
问题 How do I correctly use RESTful delete in Spring MVC controller? I have DAO that returns boolean when trying to delete some item. I am trying to delete item. If everything was OK, just show list of items (deleted item won't be there anymore). If item cannot be removed, redirect to details page and say why it couldn't be deleted. Do I need some special response status or something like this? Is my approach RESTful? @RequestMapping(value = "items/{id}", method = RequestMethod.DELETE) public

Spring MVC - Project structure - best practices [closed]

梦想的初衷 提交于 2020-01-20 13:35:19
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . What's the best approach? 1- Create multiple projects: 2- Create a single project: 回答1: I'd suggest you take a look at Spring's Project Sagan. It's the source code for their current website (http://spring.io). While they used a multi-module approach, it wasn't divided as you