Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <table>
  2.  
  3. <tr><th>File Name</th>
  4. </tr>
  5.  
  6. <tr th:each="file : ${filedata}">
  7.  
  8. <td>
  9.  
  10. <form action="#" th:action="@{~/home/ebay/getfile}" method="post" th:object="${filetobind}">
  11. <!-- th:field maps to object -->
  12. <input type="text" th:field="*{fileName}" th:value="#{file.fileName}" th:text="${file.fileName}"/>
  13. <input type="submit" value="Get" />
  14. </form>
  15.  
  16. </td>
  17.  
  18. </tr>
  19. </table>
  20.  
  21. @GetMapping(Mappings.FILES)
  22. public String getDirectory(Model model){
  23.  
  24. model.addAttribute(AttributeNames.FILE_DATA, fileService.getDirectory());
  25. model.addAttribute(AttributeNames.FILE, new DirectoryFile());
  26.  
  27.  
  28. // debug
  29. System.out.println("#############################################################");
  30. for(DirectoryFile file : fileService.getDirectory()){
  31.  
  32. System.out.println(file.getFilePath());
  33. }
  34. System.out.println("#############################################################");
  35.  
  36.  
  37. return ViewNames.DIRECTORY;
  38. }
  39.  
  40.  
  41. @PostMapping("getfile")
  42. public String getFile(Model model, @ModelAttribute(AttributeNames.FILE) DirectoryFile file ){
  43.  
  44.  
  45. System.out.println("Filepath:" + file.getFileName());
  46.  
  47. //model.addAttribute(AttributeNames.FILE, file.getFileName().trim());
  48.  
  49. return "data/" + file.getFileName();
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement