L'écriture de fichier fonctionne ! Reste à définir un rép par défaut !

This commit is contained in:
Frederic Debuire
2007-12-16 21:06:12 +00:00
parent 22b38d4fc4
commit a18df7adba
2 changed files with 17 additions and 3 deletions

View File

@@ -42,7 +42,7 @@
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="100000" />
<property name="maxUploadSize" value="10000000" />
</bean>

View File

@@ -1,5 +1,11 @@
package org.yacos.web.author.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import javax.servlet.ServletException;
@@ -23,7 +29,7 @@ public class SArticleController extends SimpleFormController {
private IArticleManager articleManager;
public ModelAndView onSubmit(Object command)
throws ServletException {
throws ServletException, IllegalStateException, IOException {
String title = ((FormSubmission) command).getTitle();
String theme = ((FormSubmission) command).getTheme();
@@ -35,13 +41,21 @@ public class SArticleController extends SimpleFormController {
System.out.println(liste);
// let's see if there's content there
MultipartFile file = ((FormSubmission) command).getFile();
if (file == null) {
// hmm, that's strange, the user did not upload anything
}
byte b[] = file.getBytes();
File file2 = new File(file.getOriginalFilename());
FileOutputStream fos = new FileOutputStream(file2);
fos.write(b);
fos.close();
Article a = new Article(0, title, theme, "", mainauthor, null, 1);
articleManager.addArticle(a);