spring-mvc

How to add headers to requests ignored by Spring Security

狂风中的少年 提交于 2021-02-18 18:48:54
问题 My configuration of Spring Security is @Override public void configure(WebSecurity web) throws Exception { web .ignoring() .antMatchers("/resources/**"); // #3 } Taken from here. The documentation for ignorig says Allows adding RequestMatcher instances that should that Spring Security should ignore. ... Typically the requests that are registered should be that of only static resources. I would like to add some headers to files served from resources. E.g.: Strict-Transport-Security: max-age

How to add headers to requests ignored by Spring Security

China☆狼群 提交于 2021-02-18 18:47:50
问题 My configuration of Spring Security is @Override public void configure(WebSecurity web) throws Exception { web .ignoring() .antMatchers("/resources/**"); // #3 } Taken from here. The documentation for ignorig says Allows adding RequestMatcher instances that should that Spring Security should ignore. ... Typically the requests that are registered should be that of only static resources. I would like to add some headers to files served from resources. E.g.: Strict-Transport-Security: max-age

What is the equivalent of @Context UriInfo in Spring Rest

五迷三道 提交于 2021-02-18 10:40:07
问题 I have worked in Jersey and RESTEasy framework earlier and now we will be using Spring Rest for a new project , I don't want to pass all the query params and matrix params as parameters in the method , and usually I would annotate the method with @Context UriInfo and would get all the parameters inside my method in Jersey or RESTEasy Framework for complex parameters. I would like to know if there is any @Context UriInfo in Spring REST, which is similar to RESTEasy or Jersey Framework. I would

redirect from method with http DELETE type to method with GET type

左心房为你撑大大i 提交于 2021-02-18 03:16:27
问题 I send my request using jquery ajax with type "DELETE". At server side I have approprite handle method that looks like this: @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) public String delete(@RequestParam("hotel") String hotelCode, @PathVariable Long id, Model model){ //delete operation return "redirect:/HotelTaxesAndCharges?hotel="+hotelCode; } and method to which I want to redirect my call after delete looks like this @RequestMapping(method = RequestMethod.GET) public

Spring configuration properties metadata json for nested list of Objects

我只是一个虾纸丫 提交于 2021-02-17 19:34:06
问题 How does one configure spring configuration metadata json for nested list of objects? Scenario @ConfigurationProperties(prefix = "custom-config") public class ConfigProperties { private boolean booleanProperty; private List<NestedObject> listProperty = new LinkedList<>(); //getters and setters } public class NestedObject { private String stringProperty; private boolean booleanProperty; //getters and setters } This is what was auto generated in the metadata json { "groups": [{ "name": "custom

Spring Controllers: Can I call a method before each @RequestMapping method is called?

前提是你 提交于 2021-02-17 14:43:27
问题 I have some common components that are always present in every page served by a given Controller class. At the beginning of each @RequestMapping method I populate the model with these common components. Is there a way to define a method be called prior to each of the controller methods so that I can get all of this copy/paste into one place? 回答1: Just annotate a method with @ModelAttribute The below would add a Foo instance to the model under the name "foo" @ModelAttribute("foo") public Foo

Spring Controllers: Can I call a method before each @RequestMapping method is called?

爷,独闯天下 提交于 2021-02-17 14:42:41
问题 I have some common components that are always present in every page served by a given Controller class. At the beginning of each @RequestMapping method I populate the model with these common components. Is there a way to define a method be called prior to each of the controller methods so that I can get all of this copy/paste into one place? 回答1: Just annotate a method with @ModelAttribute The below would add a Foo instance to the model under the name "foo" @ModelAttribute("foo") public Foo

Spring Controllers: Can I call a method before each @RequestMapping method is called?

我的梦境 提交于 2021-02-17 14:42:23
问题 I have some common components that are always present in every page served by a given Controller class. At the beginning of each @RequestMapping method I populate the model with these common components. Is there a way to define a method be called prior to each of the controller methods so that I can get all of this copy/paste into one place? 回答1: Just annotate a method with @ModelAttribute The below would add a Foo instance to the model under the name "foo" @ModelAttribute("foo") public Foo

Cannot get validation working with Spring Boot and Thymeleaf

百般思念 提交于 2021-02-17 09:22:21
问题 I have a Spring Boot application (using version 1.2.3) with 1 controller that shows a form. This all works fine, but now I want to add validation. I have this method in my controller: @RequestMapping(value = "/licensing", method = RequestMethod.POST) public String doRegistration( @Valid CustomerLicenseRegistration customerLicenseRegistration, Model model, BindingResult bindingResult ) { if( bindingResult.hasErrors()) { logger.debug( "There are errors! {}", bindingResult ); return "customer

Spring boot Ambiguous handler

元气小坏坏 提交于 2021-02-17 03:22:30
问题 I use Spring Boot. I created theses two method: @RequestMapping(value = "/user/{userId}", method = RequestMethod.GET) public UserAppDto getNameByUserId(@PathVariable("userId") Long userId) { return userService.getByUserId(userId); } @RequestMapping(value = "/user/{username}", method = RequestMethod.GET) public UserAppDto getNameByUsername(@PathVariable("username") String username) { return userService.getNameByUsername(username); } When i try to log in the web application, i get: java.lang