Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. package com.smstool
  2.  
  3. import org.springframework.dao.DataIntegrityViolationException
  4.  
  5. class UploadController {
  6.  
  7. def index() {
  8. redirect(action: "upload", params: params)
  9. }
  10.  
  11. def upload() {
  12.  
  13. }
  14.  
  15. }
  16.  
  17. <g:form action="upload" method="post" enctype="multipart/form-data">
  18. <label for="file">File:</label>
  19. <input type="file" name="file" id="file"/>
  20. <input class="save" type="submit" value="Upload"/>
  21. </g:form>
  22.  
  23. @Grab('com.xlson.groovycsv:groovycsv:1.0')
  24. import static com.xlson.groovycsv.CsvParser.parseCsv
  25.  
  26. import org.springframework.dao.DataIntegrityViolationException
  27.  
  28. class UploadController {
  29.  
  30. def index() {
  31. redirect(action: "upload", params: params)
  32. }
  33.  
  34. def upload() {
  35.  
  36.  
  37. }
  38.  
  39.  
  40. def batchUpload() {
  41.  
  42. def csv = new File('file')
  43.  
  44. //def csv = '''Name,Lastname
  45. //Mark,Andersson
  46. //Pete,Hansen'''
  47.  
  48. def data = parseCsv(csv)
  49.  
  50. for(line in data) {
  51. println "$line.Number"
  52. }
  53. }
  54.  
  55.  
  56.  
  57. }
  58.  
  59. Error 500: Internal Server Error
  60.  
  61. URI
  62. /upload/batchUpload
  63. Class
  64. groovy.lang.MissingMethodException
  65. Message
  66. No signature of method: static com.xlson.groovycsv.CsvParser.parseCsv() is applicable for argument types: (java.io.File) values: [file] Possible solutions: parseCsv(java.io.Reader), parseCsv(java.lang.String), parseCsv(java.util.Map, java.io.Reader), parseCsv(java.util.Map, java.lang.String), parse(java.io.Reader), parse(java.lang.String)
  67.  
  68. Around line 28 of grails-app/controllers/com/tool/UploadController.groovy
  69.  
  70. 25: //Mark,Andersson26: //Pete,Hansen'''27: 28: def data = parseCsv(csv)29: 30: for(line in data) {31: println "$line.Number"
  71.  
  72. Around line 195 of PageFragmentCachingFilter.java
  73.  
  74. 192: if (CollectionUtils.isEmpty(cacheOperations)) {193: log.debug("No cacheable annotation found for {}:{} {}",194: new Object[] { request.getMethod(), request.getRequestURI(), getContext() });195: chain.doFilter(request, response);196: return;197: }198:
  75.  
  76. Around line 63 of AbstractFilter.java
  77.  
  78. 60: try {61: // NO_FILTER set for RequestDispatcher forwards to avoid double gzipping62: if (filterNotDisabled(request)) {63: doFilter(request, response, chain);64: }65: else {66: chain.doFilter(req, res);
  79.  
  80. Trace
  81.  
  82. Line | Method
  83. ->> 28 | batchUpload in UploadController.groovy
  84. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  85. | 195 | doFilter in PageFragmentCachingFilter.java
  86. | 63 | doFilter . in AbstractFilter.java
  87. | 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
  88. | 603 | run . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
  89. ^ 679 | run in java.lang.Thread
  90.  
  91. <g:uploadForm action="upload">
  92. <input type="file" name="file">
  93. <g:submitButton name="upload" value="Upload"/>
  94. </g:uploadForm>
  95.  
  96. def upload() {
  97. def file = request.getFile('file')
  98. def allLines = file.inputStream.toCsvReader().readAll()
  99. ...
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement