When you want to deliver a file to a user with SpringMVC you can use the built in FileCopyUtils to put the file into the OutputStream of the response. This is an example of the method in your controller class. @RequestMapping(value = "/yourURLHere") public void handleFileDownload(HttpServletResponse response) { File file = myFileService.getFile(); response.setContentType("application/xls"); //in [...]
26 Jan
Posted by Rachel as Code, Java, Spring MVC
Part 3 of the tutorial where we introduce the SimpleFormController.
Part 2 of a tutorial series where we use Hibernate and Spring to display items from the database.
Part 1 of a tutorial series where we set up a basic web application using Spring and Hibernate
I really love Spring MVC’s annotated controllers. They are compact and nice to use but in some cases, a bit of a mission to get working. <form:select> On a report page I am working on, the user needs to have the ability to sort the result by selecting the relevant column from a select box. [...]