spring-mvc

Could not Upload File using MongoDb GridFs

拈花ヽ惹草 提交于 2020-01-06 03:53:25
问题 I'm new to Spring-Boot,i'm trying to upload file to Mongodb Database, save its objectId and link it to my document, in order to download it Later. Here is my class Person: @Document public class Person { @Id private String id; private String firstName; private String lastName; private String age; private String filename; private ObjectId file; ....} This is my controller method: @RequestMapping(value="/addperson",method=RequestMethod.POST) public String ajout(Model model,@Valid PersonForm pf)

org.springframework.validation.BeanPropertyBindingResult

寵の児 提交于 2020-01-06 03:41:08
问题 Controller class- @Controller @SessionAttributes({"id", "roleId"}) @RequestMapping("/User") public class UserController { @Autowired private UserService userv = null; @InitBinder("stdUser") private void initBinder(WebDataBinder binder) { System.out.println("1111======"+binder.getObjectName()); binder.setValidator(new NewUserValidator()); System.out.println("2222======"+binder.getObjectName()); } @RequestMapping(value = "/allUsers") public ModelAndView allUser(@ModelAttribute("userSetup")

Spring data @transactional not rolling back with SQL Server and after runtimeexception

老子叫甜甜 提交于 2020-01-06 03:41:04
问题 I've enabled my spring application to use transactions and annotated my service method accordingly but the changes to my DB persist when a RuntimeException is thrown. My Spring configuration looks like this: <!-- Data Source. --> <jee:jndi-lookup id="dataSource" jndi-name="java:/jdbc/BeheermoduleDS"/> <!-- JPA Entity Manager. --> <jee:jndi-lookup id="entityManagerFactory" jndi-name="java:/jpa/BeheermoduleDS"/> <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">

Browser file download not working for a file stored on server

时光毁灭记忆、已成空白 提交于 2020-01-06 03:32:05
问题 I have a file on server which is to be downloaded using the browser download. No error is being thrown but no download window appears for the file download. Please help. My controller code is: @RequestMapping(value = "download", method = RequestMethod.GET) public void downloadFile( @ModelAttribute("path") final String path, HttpServletRequest request, HttpServletResponse response) throws Exception { try { logger.error("inside download get try"); ServletContext context = request

Custom EL functions won't be loaded because no ObjectWarpper was specified

旧时模样 提交于 2020-01-06 03:14:22
问题 My web-application uses Spring MVC and Freemarker. When it must first render a web page (using Freemarker 2.3.22) after starting up, it logs a warning message: Custom EL functions won't be loaded because no ObjectWarpper was specified (Yes, ObjectWarpper ; the error message has typo) However, I think I do have an ObjectWrapper specified in my configuration bean: <bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name=

how to configure Spring integration FTP for dynamic inbound?

限于喜欢 提交于 2020-01-06 03:14:10
问题 I am new to spring ftp integration. I want to download files from FTP server using dynamic parameters like host, username, password etc from database. I understand how to downloaded files using static parameters from properties file. I have succeeded in uploading files( ftp outbound ) using dynamic parameters by referring to Dynamic FTP Sample example. Please, help me configuring "inbound dynamic ftp" . I have successfully implemented this but I am facing few new issue with this solution.

Spring Boot Form Validation Not Working

孤街醉人 提交于 2020-01-06 02:56:04
问题 I am new on Spring Boot Application . I have search google to learn Spring Boot Application myself. I have done easiest stuff on CRUD for Spring Boot Application but facing one problem regarding form validation . I have paste code here with if any one help me to find out problem for form validation. User.java UserController.java createUser.jsp pom.xml <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging

Spring Security - Authentication Failure - Blank Message

只谈情不闲聊 提交于 2020-01-06 02:40:24
问题 I am working on a spring-mvc web application. On my login page if user enters bad credentials I want to display an error message. So I tried to use spring security for showing error message, but I am get unable to display any message. login.jsp for login form I have done binding as : <form method="post" action="<c:url value='/j_spring_security_check' />" id="loginForm"> .... login ui </form> for displaying the error: <c:if test="${not empty param.error}"> <div> <c:out value="${SPRING_SECURITY

JsonMappingException: Can not construct instance of CommonsMultipartFile

蹲街弑〆低调 提交于 2020-01-06 02:36:05
问题 I using Spring-MVC 3, and in my application, I am sending some information with multiple attachments and each one this files have one title, Id etc. So, I made one DTO as follows public class MyDTO { Long id; Integer age; MultipartFile infoFile; // getter setter I am just creating one JSON object according to above DTO class in my JS file. Here is my Controller mapping: @RequestMapping(value = "/saveInfo", method = RequestMethod.POST) public @ResponseBody String saveInfo( @RequestParam(value

How to show image from H2 database to Thymeleaf?

浪尽此生 提交于 2020-01-05 23:59:37
问题 I'm doing spring boot, using H2 database, thymeleaf view. I have a form to upload image to save into H2 database(byte[] image), In thymeleaf, how to show image? anyone tell me the solution? controller: @RequestMapping(value = "user/new", method = RequestMethod.GET) public String newBeans(Model model) { model.addAttribute("usersss", new Beans()); return "userform"; } @RequestMapping(value = "user", method = RequestMethod.POST) public String saveUser(Beans beans) { RepositoryUser.save(beans);