spring-mvc

RequestMapping leads to 404 Error

▼魔方 西西 提交于 2021-01-27 22:13:59
问题 I'm trying to call a delete method from my jsp. It should map to the delete method in my controller. That's my code: In JSP: <td><a href="deleteEntry/${product.name}">Delete Entry</a></td> In Controller: @Controller @RequestMapping(value="/productbook") public class ProductController { @RequestMapping(value = "/deleteEntry/{name}") public ModelAndView deleteEntry(@PathVariable String name){ System.out.println("I'm HERE"); . ... some code } I always get a 404 error when clicking my delete link

Spring MVC: Can not deserialize instance of out of START_ARRAY token

谁说胖子不能爱 提交于 2021-01-27 17:42:19
问题 I have been beating my head against this for a while now and still no joy. I am new to Spring and could really use some help. I am trying to use Spring Boot to return a list of codes from a DB table. When I call my REST controller from a URL in a browser... Example URL: localhost:8081/cis/utl/lookupchoice/O.s/ It returns this: [ {"lookupId":10,"choiceGroup":"O.s","choiceCode":null,"displayLabel":"Pending","hidden":false,"displayOrder":1}, {"lookupId":11,"choiceGroup":"O.s","choiceCode":null,

@Transactional in the controller

落爺英雄遲暮 提交于 2021-01-27 17:09:31
问题 First of all I want to mention that I fully agree to only make the service layer transactional, but sometimes world is not perfect, and right now I´m in the middle of that situation. Basically I have been assigned into a wonderful project with a legacy code of 4+ years. The thing is that the developers did not follow any pattern where to introduce the bussines logic so you can image multiples services call from the controller and after that some extra call to private method into the

Custom annotation is not working on spring Beans

二次信任 提交于 2021-01-27 15:55:57
问题 I have created my new custom annotation @MyCustomAnnotation @Target({ElementType.METHOD, ElementType.TYPE, ElementType.FIELD}) @Retention(RUNTIME) public @interface MyCustomAnnotation{ } I applied that annotation on component and bean. Here is the code, @MyCustomAnnotation @Component public class CoreBussinessLogicHandler implements GenericHandler<BussinessFile> { //some bussiness logic } And @Configuration public class BussinessConfig { @Autowired private CoreIntegrationComponent

POST and GET for the same URL - Controller - Spring

别来无恙 提交于 2021-01-27 15:50:10
问题 I have this Controller : @Controller public class HelloWorldController { @RequestMapping("/hello.html") public ModelAndView helloWorld() { String message = "Hello World, Spring 3.0!"; return new ModelAndView("hello", "message", message); } @RequestMapping(value = "/login", method = RequestMethod.GET) public String viewLogin(Map<String, Object> model) { User user = new User(); model.put("userForm", user); return "LoginForm"; } @RequestMapping(value = "/login", method = RequestMethod.POST)

POST and GET for the same URL - Controller - Spring

你。 提交于 2021-01-27 15:31:53
问题 I have this Controller : @Controller public class HelloWorldController { @RequestMapping("/hello.html") public ModelAndView helloWorld() { String message = "Hello World, Spring 3.0!"; return new ModelAndView("hello", "message", message); } @RequestMapping(value = "/login", method = RequestMethod.GET) public String viewLogin(Map<String, Object> model) { User user = new User(); model.put("userForm", user); return "LoginForm"; } @RequestMapping(value = "/login", method = RequestMethod.POST)

Custom annotation is not working on spring Beans

拥有回忆 提交于 2021-01-27 14:55:21
问题 I have created my new custom annotation @MyCustomAnnotation @Target({ElementType.METHOD, ElementType.TYPE, ElementType.FIELD}) @Retention(RUNTIME) public @interface MyCustomAnnotation{ } I applied that annotation on component and bean. Here is the code, @MyCustomAnnotation @Component public class CoreBussinessLogicHandler implements GenericHandler<BussinessFile> { //some bussiness logic } And @Configuration public class BussinessConfig { @Autowired private CoreIntegrationComponent

Add (custom) decoder to WebMVC endpoint

久未见 提交于 2021-01-27 12:48:30
问题 I have a WebMVC endpoint: @RequestMapping(path = "/execution/{id}", method = RequestMethod.POST) public ResponseEntity<...> execute(@PathVariable String id) { ... } Here, the provided id should be decoded first. Is it possible to define an annotation which does this "in the background"; that is, prior to calling the endpoint? Something in the lines of: @RequestMapping(path = "/execution/{id}", method = RequestMethod.POST) public ResponseEntity<...> execute(@PathVariable @DecodedIdentifier

How to handle jackson deserialization error for all kinds of data mismatch in spring boot

丶灬走出姿态 提交于 2021-01-27 07:36:48
问题 I know there is some similar questions here about how to parse ENUM, how to parse customize JSON structure. But here my question is how to just give a better message when the user submit some JSON with is not as expected. This is the code: @PutMapping public ResponseEntity updateLimitations(@PathVariable("userId") String userId, @RequestBody LimitationParams params) { Limitations limitations = user.getLimitations(); params.getDatasets().forEach(limitations::updateDatasetLimitation); params

How to handle jackson deserialization error for all kinds of data mismatch in spring boot

两盒软妹~` 提交于 2021-01-27 07:36:23
问题 I know there is some similar questions here about how to parse ENUM, how to parse customize JSON structure. But here my question is how to just give a better message when the user submit some JSON with is not as expected. This is the code: @PutMapping public ResponseEntity updateLimitations(@PathVariable("userId") String userId, @RequestBody LimitationParams params) { Limitations limitations = user.getLimitations(); params.getDatasets().forEach(limitations::updateDatasetLimitation); params