This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch feature/sitemesh3-upload
in repository https://gitbox.apache.org/repos/asf/struts-examples.git
commit 51baa1194064be94afa5114adeef0c9872bfe9c1
Author: Lukasz Lenart
AuthorDate: Tue May 20 06:57:40 2025 +0200
Integrates upload example with Sitemesh 3
It doesn't work with the latest changes but works with 7.0.3
---
file-upload/src/main/webapp/WEB-INF/web.xml| 8 +--
sitemesh3/pom.xml | 21 +++-
.../struts/examples/sitemesh3/UploadAction.java| 60 ++
sitemesh3/src/main/resources/log4j2.xml| 4 +-
sitemesh3/src/main/resources/struts.xml| 3 ++
sitemesh3/src/main/webapp/WEB-INF/admin/hello.jsp | 3 +-
sitemesh3/src/main/webapp/WEB-INF/admin/index.jsp | 3 +-
.../main/webapp/WEB-INF/decorators/decorator.html | 2 +-
.../main/webapp/WEB-INF/decorators/decorator1.html | 2 +-
.../main/webapp/WEB-INF/decorators/decorator2.html | 2 +-
.../{decorator2.html => upload-decorator.html} | 4 +-
sitemesh3/src/main/webapp/WEB-INF/hello1.jsp | 1 +
sitemesh3/src/main/webapp/WEB-INF/hello2.jsp | 3 +-
sitemesh3/src/main/webapp/WEB-INF/index.jsp| 2 +
sitemesh3/src/main/webapp/WEB-INF/sitemesh3.xml| 1 +
sitemesh3/src/main/webapp/WEB-INF/upload.jsp | 30 +++
sitemesh3/src/main/webapp/WEB-INF/web.xml | 4 +-
sitemesh3/src/main/webapp/index.html | 10
18 files changed, 123 insertions(+), 40 deletions(-)
diff --git a/file-upload/src/main/webapp/WEB-INF/web.xml
b/file-upload/src/main/webapp/WEB-INF/web.xml
index d8d850c..34471f9 100644
--- a/file-upload/src/main/webapp/WEB-INF/web.xml
+++ b/file-upload/src/main/webapp/WEB-INF/web.xml
@@ -9,14 +9,16 @@
struts2
-
-org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
-
+
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
+FORWARD
+REQUEST
struts2
/*
+FORWARD
+REQUEST
diff --git a/sitemesh3/pom.xml b/sitemesh3/pom.xml
index 5e55393..e07af91 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 000..c2b3f85
--- /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