spring-mvc

How to serve static resources using Spring's mvc:resources on WebLogic?

我只是一个虾纸丫 提交于 2020-04-30 12:18:23
问题 We have a web app that works beautifully on tomcat, but fails to run on a latest weblogic cause of static resource loading issues - basically we serve all resources from /static/** and have set this up in the spring servlet xml file like this: <mvc:resources mapping="/static/**" location="/static/" /> This works on tomcat, but on weblogic you simply see an ugly page as all CSS/JS/jpgs within the static directoty cannot be found. I played with this, too: <mvc:default-servlet-handler /> I

@Valid working with @ModelAttribute, not with @RequestAttribute

你。 提交于 2020-04-30 06:39:06
问题 I'm implementing a @RestController and I realized that @Valid is working with @RequestBody or @ModelAttribute params of a @GetMapping method, but not with a @RequestAttribute parameter. To get validated the @RequestAttribute annotated param I have to annotate my Controller class with @Validated . Following my code: Controller @Log4j2 @RestController @RequestMapping("/test/api/v1/entity") public class MyController extends SomeController { @GetMapping("/getInfo") public ResponseEntity<

Spring Boot with redirecting with single page angular2

徘徊边缘 提交于 2020-04-29 05:48:05
问题 I have a single page Angular app with Spring Boot. It looks like the following: src main java controller HomeController CustomerController OtherController webapp js/angular-files.js index.html Spring boot correctly defaults to webapp folder and serves index.html file. What I am looking to do is: For every local REST request not starting with /api overwrite and redirect to default webapp/index.html. I plan to serve anything /api to the spring controllers. Is there a way to prefix all

Java app build fails with Mysql url pointing to a Docker Container

孤人 提交于 2020-04-16 05:13:12
问题 I have a Java App which needs to connect to MySQL. On providing url: jdbc:mysql://localhost:3306/<dbname> I am able to build the Jar. I, however, want to run it on a Docker Container in a network where I also have a MySQL container with name mysqlindocker running. To build the Jar I put in URL as jdbc:mysql://mysqlindocker:3306/<dbname> which I hope would work on running inside the container. But I fail to do it because the build fails. My guess is that on my local machine Spring is not able

What is @PostMapping annotation in Spring Web MVC?

爷,独闯天下 提交于 2020-04-16 03:15:07
问题 For what purpose @PostMapping annotation is used in Spring MVC? 回答1: @PostMapping is a composed annotation that acts as a shortcut for @RequestMapping(method = RequestMethod.POST) . @PostMapping annotated methods handle the HTTP POST requests matched with given URI expression. e.g. @PostMapping(path = "/members", consumes = "application/json", produces = "application/json") public void addMember(@RequestBody Member member) { //code } Follows this :example Hope this helps..! 回答2: Spring

Could not bind properties

老子叫甜甜 提交于 2020-04-12 11:34:28
问题 I've updated Spring Boot from version 1.5.6 to 2.0.0 and a lot of problems have started. One is the problem given in the subject. I have a class with properties @Data @ConfigurationProperties("eclipseLink") public class EclipseLinkProperties { ... } which I use in configuration @Configuration @EnableConfigurationProperties(EclipseLinkProperties.class) public class WebDatasourceConfig { ... } during compilation, he throws me away 2018-03-18 18:44:58.560 INFO 3528 --- [ main] trationDelegate

Could not bind properties

浪子不回头ぞ 提交于 2020-04-12 11:32:53
问题 I've updated Spring Boot from version 1.5.6 to 2.0.0 and a lot of problems have started. One is the problem given in the subject. I have a class with properties @Data @ConfigurationProperties("eclipseLink") public class EclipseLinkProperties { ... } which I use in configuration @Configuration @EnableConfigurationProperties(EclipseLinkProperties.class) public class WebDatasourceConfig { ... } during compilation, he throws me away 2018-03-18 18:44:58.560 INFO 3528 --- [ main] trationDelegate

Could not bind properties

*爱你&永不变心* 提交于 2020-04-12 11:32:06
问题 I've updated Spring Boot from version 1.5.6 to 2.0.0 and a lot of problems have started. One is the problem given in the subject. I have a class with properties @Data @ConfigurationProperties("eclipseLink") public class EclipseLinkProperties { ... } which I use in configuration @Configuration @EnableConfigurationProperties(EclipseLinkProperties.class) public class WebDatasourceConfig { ... } during compilation, he throws me away 2018-03-18 18:44:58.560 INFO 3528 --- [ main] trationDelegate

Send javascript variables to spring controller

余生颓废 提交于 2020-04-11 12:59:46
问题 I'm trying to develop simple application using spring mvc and I need to pass javascript parameters to spring controller. I have tried several methods and none of them were worked. Following is my javascript and spring controller. Please help me to sort this issue. Java script function searchViaAjax(id) { alert(id); $.ajax({ type : "POST", contentType : "application/json", url : "search/api/getSearchResult", data : JSON.stringify(id), dataType : 'json', timeout : 100000, success : function(id)

Spring boot 1.5.9, 404 error while accessing resources images within Docker container

痞子三分冷 提交于 2020-04-11 06:50:05
问题 The bounty expires in 3 days . Answers to this question are eligible for a +100 reputation bounty. Dimitri Kopriwa is looking for an answer from a reputable source : I am still experiencing this and I am willing to help and add further information to understand and solve this issue. Currently, I am moving forward with a NodeJS fallback solution which will expose publicly those images. In a Spring Boot 1.5.9 application I want to access static resources through HTTP using Google Chrome. In