Spring for Dummy

38 views
Skip to first unread message

Emiliano

unread,
Feb 11, 2015, 11:47:00 AM2/11/15
to openlega...@googlegroups.com
In my OrderRowDetailCtrl I have a custo method to upload file.
I created (copied) my firts java controller.
When I try to upload the file I receive:

GRAVE: Servlet.service() for servlet appServlet threw exception

org.springframework.web.multipart.MultipartException: The current request is not a multipart request


What I have to configure and how ?

PS: Is it possible to fix Excel button error ?

controllers.js
FileManager.java

to...@openlegacy.com

unread,
Feb 11, 2015, 12:49:46 PM2/11/15
to openlega...@googlegroups.com

Roi Mor

unread,
Feb 11, 2015, 1:59:44 PM2/11/15
to openlega...@googlegroups.com
Emiliano,

I see the example I sent you by mail (openlegacy-rest-db-sample) is using FileUploader (angular-file-upload.min.js)
It is used in controllers.js within the sample project, and uploaded to TreeController (which I assume you used).

Attached the sample again for the audience.
openlegacy-rest-db-sample.zip

Emiliano

unread,
Feb 12, 2015, 3:19:18 AM2/12/15
to openlega...@googlegroups.com
Yes, I made a bit of confusion: I mixed up the two example (gallery item page and db-sample) and forget some piece of code.
Today I'll investigate the issue :-)

Emiliano

unread,
Feb 12, 2015, 11:54:33 AM2/12/15
to openlega...@googlegroups.com
Ok, now I can upload images!!! :-)
They are stored (as a first step, for simplicity) in the "user.home"/images
How to serve it as static url from Tomcat ? My idea is to create a method that returns a list of url to display in my gallery item page.

Il giorno mercoledì 11 febbraio 2015 19:59:44 UTC+1, Roi Mor ha scritto:

Roi Mor

unread,
Feb 12, 2015, 12:30:10 PM2/12/15
to openlega...@googlegroups.com
The sample app expose list of files for each node in the product tree and a link to download for each file.
TreeController does the Url mappings.

Emiliano

unread,
Feb 12, 2015, 12:59:33 PM2/12/15
to openlega...@googlegroups.com
I saw, Roi ... but I need something else.
The images are stored to a folder (not in H2 memory db) outside the webapp root and I want to display (not download) an images gallery like the one in the rest/mobile sample.
I tryed to add  <mvc:resources mapping="/images/**" location="file:///C:/Users/Emiliano/images/" /> to webmvc-config.xml, but nothing changed.




Il giorno giovedì 12 febbraio 2015 18:30:10 UTC+1, Roi Mor ha scritto:

Roi Mor

unread,
Feb 12, 2015, 1:03:48 PM2/12/15
to openlega...@googlegroups.com
In Spring MVC you map the image link to a controller Java method, read the file content as bytes and write them to the response.
We will find an example from one of our project, and share it.

Roi Mor

unread,
Feb 12, 2015, 1:06:44 PM2/12/15
to openlega...@googlegroups.com
Here is an example which streams a PDF file from a local folder to the http client :
@Controller
public class FilesController {

private String directory = "c:\\temp";

@RequestMapping(value="mifrat/{mifrat}",method=RequestMethod.GET)
public void getMifrat(HttpServletResponse response,@PathVariable("mifrat") String mifrat) throws IOException {
response.setContentType("application/pdf");

File file = new File(directory,"mifrat_ " + mifrat.replaceAll(" -", "") +".pdf");
byte[] bytes = FileUtils.readFileToByteArray(file);
response.getOutputStream().write(bytes);

}

public void setDirectory(String directory) {
this.directory = directory;
}
}
Reply all
Reply to author
Forward
0 new messages