spring-mvc

How to upload file in spring?

与世无争的帅哥 提交于 2021-02-16 14:59:41
问题 I am not able to get the file name in spring controller <form:form method="post" modelAttribute="sampleDetails" enctype="multipart/form-data"> <input type="file" name="uploadedFileName" id="fileToUpload" required="" > <input type="submit" name="import_file" value="Import File" id="" /> </form:form> Its my post method in controller @RequestMapping(method = RequestMethod.POST) public String importQuestion(@Valid @RequestParam("uploadedFileName") MultipartFile multipart, @ModelAttribute(

Size limit with spring MVC POST form?

柔情痞子 提交于 2021-02-16 14:26:09
问题 I have a form : <form:form modelAttribute="zgImport" action="${importAfterValidationUsers}" method="POST" name="ImportForm" > in which I display csv content (one line per user). My controller method get the object : public void importAfterValidationUsers(@ModelAttribute ("zgImport") ZgImport zgImport, ActionRequest request, ActionResponse response) { Problem is : if I have many lines (more than 670) the object "zgImport" that I get in my controller is not fully filed, I miss some data. Is

configure spring.codec.max-in-memory-size When using ReactiveElasticsearchClient

北城余情 提交于 2021-02-16 10:07:19
问题 I am using the ReactiveElasticsearchClient from spring-data-elasticsearch 3.2.3 with spring-boot 2.2.0. When upgrading to spring-boot 2.2.2 i have got org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144. It's indicated to fixe that to use spring.codec.max-in-memory-size but i still got the same exception. Bellow the whole exception: org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer :

configure spring.codec.max-in-memory-size When using ReactiveElasticsearchClient

China☆狼群 提交于 2021-02-16 10:06:21
问题 I am using the ReactiveElasticsearchClient from spring-data-elasticsearch 3.2.3 with spring-boot 2.2.0. When upgrading to spring-boot 2.2.2 i have got org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer : 262144. It's indicated to fixe that to use spring.codec.max-in-memory-size but i still got the same exception. Bellow the whole exception: org.springframework.core.io.buffer.DataBufferLimitException: Exceeded limit on max bytes to buffer :

Jsp page on Spring mvc renders to whitescreen on page refresh

走远了吗. 提交于 2021-02-11 17:19:26
问题 Inside our application, we are randomly getting below issue while submitting requests. (occuring in different pages). On request submission,page suddenly goes blank. We have multiple dropdowns in Jsp page. On selecting some of the drop-down , form submission happens to populate other dropdowns. We found that new modelandview is returned from controller, but page goes blank. When we refresh the url, application is available again. Weird thing is , it doesn't not occur always even for same

springMVC upload file exception

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-11 15:36:34
问题 @ResponseBody @RequestMapping(value="addMultiDisCar",method=RequestMethod.POST) public Map<String, Object> addMultiDisCar(HttpServletRequest request,File uploadFile){ User user=(User) request.getSession().getAttribute("loginUser"); Boolean isAdmin = authorityUtils.checkFunctionURL("distriCarMng.admin", user.getRoleList()); Boolean hasApprove = authorityUtils.checkFunctionURL("distriCarMng.audit", user.getRoleList()); Boolean hasDistri = authorityUtils.checkFunctionURL("distriCarMng

Starting Spring boot REST controller in two ports

若如初见. 提交于 2021-02-11 15:35:21
问题 Is there a way to have two rest controller running on two different ports from one spring boot application ? Say for example Controller_A running in http://localhost:8080 and Controller_B running in http://localhost:9090 in one SpringBoot main Application ? 回答1: One way of doing this is actually creating two application properties; app-A.properties server.port=8080 app-B.properties server.port=9090 And then in your controllers, put annotation like below; @Profile("A") public class ControllerA

springMVC upload file exception

蹲街弑〆低调 提交于 2021-02-11 15:35:21
问题 @ResponseBody @RequestMapping(value="addMultiDisCar",method=RequestMethod.POST) public Map<String, Object> addMultiDisCar(HttpServletRequest request,File uploadFile){ User user=(User) request.getSession().getAttribute("loginUser"); Boolean isAdmin = authorityUtils.checkFunctionURL("distriCarMng.admin", user.getRoleList()); Boolean hasApprove = authorityUtils.checkFunctionURL("distriCarMng.audit", user.getRoleList()); Boolean hasDistri = authorityUtils.checkFunctionURL("distriCarMng

How to create a link from two parts in thymeleaf?

旧时模样 提交于 2021-02-11 14:16:49
问题 I am newbie in thymeleaf. I need to create links that consists of the path to controller(class PersonController) and id of object, which I take from list. I want that eachPerson object from list have its own link like this: href=" /personData/person.id'. It's my code, which give me an error org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing: <div th:each="person : ${persons}" th:with="hrefToPerson=${/personData/ + ${person.id}}"> <a th:href=hrefToPerson

Uploading files on to server using spring mvc

岁酱吖の 提交于 2021-02-11 14:12:21
问题 I am trying to upload list of files to the server using spring MVC. But i am able to store on to the c drive,but i don't know how to upload onto server.Please help me. 回答1: create a folder inside the Tomcat 9 (server) directory as follows .../Apache Software Foundation/Tomcat 9/FileUpload then, you can access the above directory (FileUpload) in java File fileUpload = new File(System.getProperty("catalina.base"), "FileUpload"); but, if you use the eclipse ide, in the development time you