spring-mvc

Enable Cors using Spring 3.0.4

余生颓废 提交于 2021-02-19 04:23:04
问题 I'm using Java Spring 3.0.4 (can't upgrade due to some requirements) and I need to enable Cors in order for my front-end to talk to my back-end. My back-end is an angular application running on: http://localhost:4200/home I have tried the following with no luck: public static final String CREDENTIALS_NAME = "Access-Control-Allow-Credentials"; public static final String ORIGIN_NAME = "Access-Control-Allow-Origin"; public static final String METHODS_NAME = "Access-Control-Allow-Methods"; public

How to make spring security to call the requested resource after a successful authentication?

混江龙づ霸主 提交于 2021-02-19 03:46:52
问题 The title might be a bit misleading and might give you the impression this is an easy one so I will elaborate. I have a set of endpoints (REST services) that I want to secure without using the regular login way that Spring security provides. Usually you would first aim to the login endpoint (j_pring_security_check by default), authenticate and then send the request to the service endpoint along with the JSESSIONID. In this case i want to work without redirections. From the client-side I want

Spring Boot doesn't use CommonsMultipartResolver?

吃可爱长大的小学妹 提交于 2021-02-19 03:36:07
问题 I have a problem with REST web service running with Spring Boot (Jetty). One of my REST method is file upload and I'm guessing that CommonsMultipartResolver is not using during multipart requests. Signature of this upload method is : @ResponseBody @RequestMapping(value = "/upload", method = RequestMethod.POST, produces = "application/json") public BaseResponse upload(@RequestParam("login") String login, @RequestParam("passwd") String passwd, @RequestParam("partner") String partner,

Spring Boot doesn't use CommonsMultipartResolver?

纵然是瞬间 提交于 2021-02-19 03:36:06
问题 I have a problem with REST web service running with Spring Boot (Jetty). One of my REST method is file upload and I'm guessing that CommonsMultipartResolver is not using during multipart requests. Signature of this upload method is : @ResponseBody @RequestMapping(value = "/upload", method = RequestMethod.POST, produces = "application/json") public BaseResponse upload(@RequestParam("login") String login, @RequestParam("passwd") String passwd, @RequestParam("partner") String partner,

Ajax pass a “Map” object to Spring MVC Controller

我的梦境 提交于 2021-02-19 01:47:30
问题 It seems like Spring MVC doesn't know how to map a javascript "map" to a Java map object In the web UI, say, foo.jsp, <script> var myMap = {}; myMap["people"] = ["Alex","Bob","Charles","Dave"]; myMap["fruit"] = ["Apple","Orange"]; $.ajax({ type : "POST", url : "/myURL", data : "myMap=" + myMap, // I tried "myMap="+JSON.stringify(myMap), as well, it doesn't work neither success : function(response) { alert("Success! response = " + response); }, error : function(e) { alert("AJAX error"); } });

No mapping found for HTTP request with URI [] in DispatcherServlet with name ' [duplicate]

人盡茶涼 提交于 2021-02-19 01:16:31
问题 This question already has answers here : Why does Spring MVC respond with a 404 and report “No mapping found for HTTP request with URI […] in DispatcherServlet”? (11 answers) Closed 4 years ago . Morning, I already checked most of the answers to this problem (No mapping found for HTTP request with URI.... in DispatcherServlet with name) and also (No mapping found for HTTP request with URI [/ChickenTest/index] in DispatcherServlet with name 'dispatcherServlet') but I'm still getting "No

Is there a way to integrate java bean validation api With Spring RestTemplate

≡放荡痞女 提交于 2021-02-19 01:15:56
问题 Is there a way to integrate spring RestTemplate with JavaBean validation api. ? I know there is a integration for spring controller. you can put @Valid on request body param and if Employee is not valid you will get MethodArgumentNotValidException exception . which you can handel in exception handler class. @PostMapping(value = "/add", produces = APPLICATION_JSON_VALUE) public ResponseEntity<String> addEmployee( @RequestBody @Valid Employee emp) { //... } But what I want is similar way to

Is there a way to integrate java bean validation api With Spring RestTemplate

╄→尐↘猪︶ㄣ 提交于 2021-02-19 01:08:50
问题 Is there a way to integrate spring RestTemplate with JavaBean validation api. ? I know there is a integration for spring controller. you can put @Valid on request body param and if Employee is not valid you will get MethodArgumentNotValidException exception . which you can handel in exception handler class. @PostMapping(value = "/add", produces = APPLICATION_JSON_VALUE) public ResponseEntity<String> addEmployee( @RequestBody @Valid Employee emp) { //... } But what I want is similar way to

Is there a way to integrate java bean validation api With Spring RestTemplate

旧巷老猫 提交于 2021-02-19 01:07:25
问题 Is there a way to integrate spring RestTemplate with JavaBean validation api. ? I know there is a integration for spring controller. you can put @Valid on request body param and if Employee is not valid you will get MethodArgumentNotValidException exception . which you can handel in exception handler class. @PostMapping(value = "/add", produces = APPLICATION_JSON_VALUE) public ResponseEntity<String> addEmployee( @RequestBody @Valid Employee emp) { //... } But what I want is similar way to

What's the default Spring 3 view resolver?

前提是你 提交于 2021-02-18 22:24:47
问题 I've read Spring 3 docs about view resolvers... But in my project I didn't define any. I just return a ModelAndView or @ResponseBody String from the controller methods. I guess there is a default view resolver (perhaps UrlBasedViewResolver ) that is already configured. What is that? Where can I get info in the docs about this? If I want to add other views like JsonView or XmlView (right now I use a Jsp that renders the data, but I read I can avoid this by passing model Objects directly to