java - Display text value in a form or a textArea, textForm by GSP and Groovy code -


so have uploadform , after choosed file upload,and submit,and therefore want display content of file documents textarea or form,but don't know how parameter file , render text in file.
here code:file displayform.gsp

<%@ page contenttype="text/html;charset=utf-8" %> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> <meta name="layout" content="main"/> <title>upload</title> </head> <body> <div class="body"> </div> <g:uploadform action ="uploaded" >     <input type = "file" name = "cfile" value = "file"/>     <g:actionsubmit  action="displayform" value = "submit" /> </g:uploadform>     <p>         <textfield rows="50" cols="100" value = "${cfile}"         name="displayresult"/ >               </p>     <input type="button" value = "display" name = "display">     <br /> </body> </html>   

and file samplecontroller.groovy:

class samplecontroller{ def f def displayform() {     if(params.cfile){         if(params.cfile instanceof        org.springframework.web.multipart.commons.commonsmultipartfile){                  //new fileoutputstream('d:/submitted_file.txt').leftshift( params.cfile.getinputstream() );             f=params.cfile.transferto(new file('d:/submitted_file.uima'));             render file:params.cfile.tostring() ,contenttype: "text", encoding:"utf-8"           }else{             log.error("wrong attachment type [${cfile.getclass()}]");         }     } } 

as can see above,i wan't read file 'd:/submitted_file.uima' , render it.
if call render method,it got error file null.

i got problem @ call file parameter file .gsp.should call name "cfile" or "value" or "id" or uploadform , textarea(textfield).

the render file:x method accepts byte[], java.io.file or inputstream parameters while seem passing in commonsmultipartfile. try calling render file: f, ... in above code, instead, render file saved disk.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -