diff --git a/sitemesh3/pom.xml b/sitemesh3/pom.xml index 5e553931..e07af914 100644 --- a/sitemesh3/pom.xml +++ b/sitemesh3/pom.xml @@ -14,7 +14,13 @@ war + + + 7.0.3 @@ -35,21 +41,6 @@ log4j-slf4j-impl ${log4j2.version} - - - org.apache.struts - struts2-junit-plugin - ${struts2.version} - test - - - - junit - junit - 4.13.2 - test - - diff --git a/sitemesh3/src/main/java/org/apache/struts/examples/sitemesh3/UploadAction.java b/sitemesh3/src/main/java/org/apache/struts/examples/sitemesh3/UploadAction.java new file mode 100644 index 00000000..c2b3f85a --- /dev/null +++ b/sitemesh3/src/main/java/org/apache/struts/examples/sitemesh3/UploadAction.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.struts.examples.sitemesh3; + +import org.apache.struts2.ActionSupport; +import org.apache.struts2.action.UploadedFilesAware; +import org.apache.struts2.dispatcher.multipart.UploadedFile; + +import java.io.File; +import java.util.List; + +/** + * Allows upload a file + */ +public class UploadAction extends ActionSupport implements UploadedFilesAware { + + private File[] upload; + private String[] uploadFileName; + private String[] uploadContentType; + + public String execute() throws Exception { + return INPUT; + } + + public File[] getUpload() { + return upload; + } + + public String[] getUploadFileName() { + return uploadFileName; + } + + public String[] getUploadContentType() { + return uploadContentType; + } + + @Override + public void withUploadedFiles(List uploadedFiles) { + upload = uploadedFiles.stream().map(UploadedFile::getContent).toArray(File[]::new); + uploadFileName = uploadedFiles.stream().map(UploadedFile::getName).toArray(String[]::new); + uploadContentType = uploadedFiles.stream().map(UploadedFile::getContentType).toArray(String[]::new); + } +} diff --git a/sitemesh3/src/main/resources/log4j2.xml b/sitemesh3/src/main/resources/log4j2.xml index 1f4e3df4..9793da52 100644 --- a/sitemesh3/src/main/resources/log4j2.xml +++ b/sitemesh3/src/main/resources/log4j2.xml @@ -2,13 +2,13 @@ - + - + diff --git a/sitemesh3/src/main/resources/struts.xml b/sitemesh3/src/main/resources/struts.xml index 7048cff6..875a3dbb 100644 --- a/sitemesh3/src/main/resources/struts.xml +++ b/sitemesh3/src/main/resources/struts.xml @@ -20,6 +20,9 @@ /WEB-INF/error.jsp + + /WEB-INF/upload.jsp + diff --git a/sitemesh3/src/main/webapp/WEB-INF/admin/hello.jsp b/sitemesh3/src/main/webapp/WEB-INF/admin/hello.jsp index b3e711e3..c1ded3a4 100644 --- a/sitemesh3/src/main/webapp/WEB-INF/admin/hello.jsp +++ b/sitemesh3/src/main/webapp/WEB-INF/admin/hello.jsp @@ -6,9 +6,10 @@

SiteMesh example: Admin Index with Default Decorator

- + Hello +Admin Index \ No newline at end of file diff --git a/sitemesh3/src/main/webapp/WEB-INF/admin/index.jsp b/sitemesh3/src/main/webapp/WEB-INF/admin/index.jsp index b3e711e3..3494e57f 100644 --- a/sitemesh3/src/main/webapp/WEB-INF/admin/index.jsp +++ b/sitemesh3/src/main/webapp/WEB-INF/admin/index.jsp @@ -6,7 +6,8 @@

SiteMesh example: Admin Index with Default Decorator

- +Index + Hello diff --git a/sitemesh3/src/main/webapp/WEB-INF/decorators/decorator.html b/sitemesh3/src/main/webapp/WEB-INF/decorators/decorator.html index 2d7835d8..3088e6c8 100644 --- a/sitemesh3/src/main/webapp/WEB-INF/decorators/decorator.html +++ b/sitemesh3/src/main/webapp/WEB-INF/decorators/decorator.html @@ -1,4 +1,4 @@ - + <sitemesh:write property="title"/> diff --git a/sitemesh3/src/main/webapp/WEB-INF/decorators/decorator1.html b/sitemesh3/src/main/webapp/WEB-INF/decorators/decorator1.html index bbaf9082..fd434018 100644 --- a/sitemesh3/src/main/webapp/WEB-INF/decorators/decorator1.html +++ b/sitemesh3/src/main/webapp/WEB-INF/decorators/decorator1.html @@ -1,4 +1,4 @@ - + <sitemesh:write property="title"/> diff --git a/sitemesh3/src/main/webapp/WEB-INF/decorators/decorator2.html b/sitemesh3/src/main/webapp/WEB-INF/decorators/decorator2.html index 57a92c5f..db542cd3 100644 --- a/sitemesh3/src/main/webapp/WEB-INF/decorators/decorator2.html +++ b/sitemesh3/src/main/webapp/WEB-INF/decorators/decorator2.html @@ -1,4 +1,4 @@ - + <sitemesh:write property="title"/> diff --git a/sitemesh3/src/main/webapp/WEB-INF/decorators/upload-decorator.html b/sitemesh3/src/main/webapp/WEB-INF/decorators/upload-decorator.html new file mode 100644 index 00000000..bdeb46e7 --- /dev/null +++ b/sitemesh3/src/main/webapp/WEB-INF/decorators/upload-decorator.html @@ -0,0 +1,10 @@ + + + <sitemesh:write property="title"/> + + + +

Upload Decorator

+ + + diff --git a/sitemesh3/src/main/webapp/WEB-INF/hello1.jsp b/sitemesh3/src/main/webapp/WEB-INF/hello1.jsp index dee6bedd..91928fdb 100644 --- a/sitemesh3/src/main/webapp/WEB-INF/hello1.jsp +++ b/sitemesh3/src/main/webapp/WEB-INF/hello1.jsp @@ -14,5 +14,6 @@

Selected decorator:

+Index \ No newline at end of file diff --git a/sitemesh3/src/main/webapp/WEB-INF/hello2.jsp b/sitemesh3/src/main/webapp/WEB-INF/hello2.jsp index f9a2da9b..124f3896 100644 --- a/sitemesh3/src/main/webapp/WEB-INF/hello2.jsp +++ b/sitemesh3/src/main/webapp/WEB-INF/hello2.jsp @@ -5,7 +5,7 @@ SiteMesh example: Hello 2 with Decorator 2 -

SiteMesh example: Hello 2 with Decorator 2

+

SiteMesh example: Hello 2 with Decorator 2

Decorators

@@ -14,5 +14,6 @@

Selected decorator:

+Index \ No newline at end of file diff --git a/sitemesh3/src/main/webapp/WEB-INF/index.jsp b/sitemesh3/src/main/webapp/WEB-INF/index.jsp index 0bbc7cf1..1c49bdad 100644 --- a/sitemesh3/src/main/webapp/WEB-INF/index.jsp +++ b/sitemesh3/src/main/webapp/WEB-INF/index.jsp @@ -10,5 +10,7 @@
Hello +Admin +Upload \ No newline at end of file diff --git a/sitemesh3/src/main/webapp/WEB-INF/sitemesh3.xml b/sitemesh3/src/main/webapp/WEB-INF/sitemesh3.xml index f8803620..3491a254 100644 --- a/sitemesh3/src/main/webapp/WEB-INF/sitemesh3.xml +++ b/sitemesh3/src/main/webapp/WEB-INF/sitemesh3.xml @@ -3,4 +3,5 @@ + diff --git a/sitemesh3/src/main/webapp/WEB-INF/upload.jsp b/sitemesh3/src/main/webapp/WEB-INF/upload.jsp new file mode 100644 index 00000000..0674986b --- /dev/null +++ b/sitemesh3/src/main/webapp/WEB-INF/upload.jsp @@ -0,0 +1,30 @@ +<%@ page contentType="text/html; charset=UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> + + + Sitemesh example: File upload + + +

Sitemesh example: Upload with Upload Decorator

+ + + + + + + + + + + File:
+
+ + Content-Type:
+
+ + File name:
+
+ +Index + + diff --git a/sitemesh3/src/main/webapp/WEB-INF/web.xml b/sitemesh3/src/main/webapp/WEB-INF/web.xml index ff5bac74..a09fa7b1 100644 --- a/sitemesh3/src/main/webapp/WEB-INF/web.xml +++ b/sitemesh3/src/main/webapp/WEB-INF/web.xml @@ -5,7 +5,7 @@ http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> - Struts Tiles 2 Demo + Struts Sitemesh 3 Demo struts2-prepare @@ -38,7 +38,7 @@ - /index.html + /index diff --git a/sitemesh3/src/main/webapp/index.html b/sitemesh3/src/main/webapp/index.html deleted file mode 100644 index abdee369..00000000 --- a/sitemesh3/src/main/webapp/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - -

Loading ...

- -