mirror of
https://github.com/apache/struts.git
synced 2026-08-08 08:07:17 +00:00
Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5038a9209f | |||
| 2135ebf651 | |||
| c0dd8dd80c | |||
| c36eafa37a | |||
| 07603b9591 | |||
| 3227d5929a | |||
| 4a8ddbb274 | |||
| 67ba458d03 | |||
| 959b2182b2 | |||
| 6de93e77db | |||
| 59dc9301e0 | |||
| 2fc4a822a4 | |||
| 6a6270f62a | |||
| 9153228b6a | |||
| 5713a74edc | |||
| 32071c71ad | |||
| 7e4791985b | |||
| 3c1e44ca2d | |||
| 2ba8d97ad0 | |||
| cba0db0b07 | |||
| 688162cae2 | |||
| a33c162f53 | |||
| c7a6daf5ce | |||
| 370c7ce17a | |||
| 55989befce | |||
| 2e4a4b5e36 | |||
| 9d07c3b4c3 | |||
| 575e4e8c9b | |||
| 74388dfba7 | |||
| 4ee8b02262 | |||
| c8febc2050 | |||
| 3ea126388c | |||
| 09993e3476 | |||
| f5688e680b | |||
| 60a3db0a63 | |||
| 4714d27678 | |||
| 4feceee5f1 |
@@ -17,18 +17,16 @@ github:
|
||||
protected_branches:
|
||||
main:
|
||||
# contexts are the names of checks that must pass.
|
||||
required_status_checks:
|
||||
contexts:
|
||||
- "Build and Test (JDK 17)"
|
||||
contexts:
|
||||
- build
|
||||
required_pull_request_reviews:
|
||||
# it does not work because our github teams are private/secret, see INFRA-25666
|
||||
require_code_owner_reviews: false
|
||||
required_approving_review_count: 0
|
||||
release/*:
|
||||
# contexts are the names of checks that must pass.
|
||||
required_status_checks:
|
||||
contexts:
|
||||
- "Build and Test (JDK 8)"
|
||||
contexts:
|
||||
- build
|
||||
required_pull_request_reviews:
|
||||
# it does not work because our github teams are private/secret, see INFRA-25666
|
||||
require_code_owner_reviews: false
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# Set the default behavior, in case people don't have core.autocrlf set.
|
||||
* text=auto
|
||||
*.bat eol=crlf
|
||||
*.cmd eol=crlf
|
||||
*.sh eol=lf
|
||||
@@ -8,9 +8,3 @@ updates:
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
target-branch: "main"
|
||||
- package-ecosystem: "maven"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
target-branch: "release/struts-6-7-x"
|
||||
|
||||
@@ -17,9 +17,7 @@ name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
- 'release/*'
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
@@ -44,20 +42,14 @@ jobs:
|
||||
language: [ 'java' ]
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v5
|
||||
- name: Setup Java JDK
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
cache: 'maven'
|
||||
uses: actions/checkout@v4
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3.30.3
|
||||
uses: github/codeql-action/init@v3.27.1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v3.30.3
|
||||
uses: github/codeql-action/autobuild@v3.27.1
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v3.30.3
|
||||
uses: github/codeql-action/analyze@v3.27.1
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
|
||||
@@ -19,8 +19,7 @@ on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
- 'release/*'
|
||||
- master
|
||||
|
||||
permissions: read-all
|
||||
|
||||
@@ -30,25 +29,18 @@ env:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build and Test (JDK ${{ matrix.java }})${{ matrix.profile == '-Pjakartaee11' && ' with Jakarta EE 11' || matrix.profile }}
|
||||
name: Build and Test
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- java: '17'
|
||||
profile: ''
|
||||
- java: '21'
|
||||
profile: ''
|
||||
- java: '21'
|
||||
profile: '-Pjakartaee11'
|
||||
java: [ '8', '11', '17', '21' ]
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
- name: Setup Java ${{ matrix.java }}
|
||||
uses: actions/setup-java@v5
|
||||
uses: actions/checkout@v4
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: ${{ matrix.java }}
|
||||
cache: 'maven'
|
||||
- name: Maven Verify on Java ${{ matrix.java }}${{ matrix.profile == '-Pjakartaee11' && ' (Jakarta EE 11)' || matrix.profile }}
|
||||
run: mvn -B -V -DskipAssembly verify ${{ matrix.profile }} --no-transfer-progress
|
||||
- name: Build with Maven on Java ${{ matrix.java }}
|
||||
run: mvn -B -V -DskipAssembly verify --no-transfer-progress
|
||||
|
||||
@@ -20,8 +20,7 @@ on:
|
||||
schedule:
|
||||
- cron: "30 1 * * 6" # Weekly on Saturdays
|
||||
push:
|
||||
branches:
|
||||
- "main"
|
||||
branches: [ "master" ]
|
||||
|
||||
permissions: read-all
|
||||
|
||||
@@ -41,12 +40,12 @@ jobs:
|
||||
steps:
|
||||
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@v5 # 3.1.0
|
||||
uses: actions/checkout@v4 # 3.1.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # 2.4.2
|
||||
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # 2.4.0
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
@@ -58,13 +57,13 @@ jobs:
|
||||
publish_results: true
|
||||
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # 4.6.2
|
||||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # 4.4.3
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@aa90e97ad2ed17cde6a43e89f70138299e64f837 # 2.22.11
|
||||
uses: github/codeql-action/upload-sarif@acb9cb18eec7e3a113ef83cff0be91e75cfd9526 # 2.22.11
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
@@ -19,7 +19,7 @@ on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
- master
|
||||
|
||||
permissions: read-all
|
||||
|
||||
@@ -31,17 +31,17 @@ jobs:
|
||||
sonarcloud:
|
||||
name: Scan
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ !github.event.pull_request.base.repo.fork && !github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]' }}
|
||||
if: ${{ !github.event.pull_request.head.repo.fork }}
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-java@v5
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 21
|
||||
java-version: 17
|
||||
cache: 'maven'
|
||||
- env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
|
||||
run: ./mvnw -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Pcoverage -DskipAssembly
|
||||
run: mvn -B -V -Pcoverage -DskipAssembly verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar --no-transfer-progress
|
||||
|
||||
@@ -46,6 +46,3 @@ test-output
|
||||
|
||||
# Tidelift CLI scanner
|
||||
.tidelift
|
||||
|
||||
# Claude Code local settings
|
||||
.claude/
|
||||
+2
-3
@@ -14,6 +14,5 @@
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
wrapperVersion=3.3.2
|
||||
distributionType=only-script
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
|
||||
|
||||
@@ -1,210 +0,0 @@
|
||||
# Claude Code Best Practices for Apache Struts
|
||||
|
||||
This document outlines essential practices for working with Claude Code on the Apache Struts project, based on security improvements and testing implementations.
|
||||
|
||||
## Project Context
|
||||
- **Framework**: Apache Struts 2 (Java-based web framework)
|
||||
- **Technology Stack**: Jakarta EE, Maven, Java 17
|
||||
- **Key Libraries**: OGNL, Commons FileUpload2, Log4j2, JUnit, AssertJ
|
||||
- **Build System**: Maven with standard lifecycle
|
||||
|
||||
## Security-First Development
|
||||
|
||||
### Critical Security Principles
|
||||
1. **Never create files in system temp directories** - always use controlled application directories
|
||||
2. **Use UUID-based naming** for temporary files to prevent collisions and path traversal
|
||||
3. **Implement proper resource cleanup** with try-with-resources and finally blocks
|
||||
4. **Track all temporary resources** for explicit cleanup (security critical)
|
||||
5. **Validate all user inputs** and sanitize filenames before processing
|
||||
|
||||
### Security Implementation Patterns
|
||||
```java
|
||||
// GOOD: Secure temporary file creation
|
||||
protected File createTemporaryFile(String fileName, Path location) {
|
||||
String uid = UUID.randomUUID().toString().replace("-", "_");
|
||||
File file = location.resolve("upload_" + uid + ".tmp").toFile();
|
||||
LOG.debug("Creating temporary file: {} (originally: {})", file.getName(), fileName);
|
||||
return file;
|
||||
}
|
||||
|
||||
// BAD: Insecure system temp usage
|
||||
File tempFile = File.createTempFile("struts_upload_", "_" + item.getName());
|
||||
```
|
||||
|
||||
### Resource Management
|
||||
- Always use tracking collections for cleanup: `List<File> temporaryFiles`, `List<DiskFileItem> diskFileItems`
|
||||
- Implement protected cleanup methods for extensibility
|
||||
- Make cleanup idempotent and exception-safe
|
||||
- Use try-with-resources for streams and I/O operations
|
||||
|
||||
## Testing Implementation
|
||||
|
||||
### Test Structure & Coverage
|
||||
- **Unit Tests**: Test individual methods with mocked dependencies
|
||||
- **Integration Tests**: Test complete workflows with real file I/O
|
||||
- **Security Tests**: Verify directory traversal prevention, secure naming
|
||||
- **Error Handling Tests**: Test exception scenarios and error reporting
|
||||
- **Cleanup Tests**: Verify resource cleanup and tracking
|
||||
|
||||
### Testing Commands
|
||||
```bash
|
||||
# Run all tests
|
||||
mvn test -DskipAssembly
|
||||
|
||||
# Run specific test class
|
||||
mvn test -Dtest=JakartaMultiPartRequestTest
|
||||
|
||||
# Run tests with specific method pattern
|
||||
mvn test -Dtest=*MultiPartRequestTest#temporal*
|
||||
```
|
||||
|
||||
use `-DskipAssembly` to avoid building zip files with docs, examples, etc.
|
||||
|
||||
### Test Implementation Patterns
|
||||
```java
|
||||
@Test
|
||||
public void securityTestExample() throws Exception {
|
||||
// given - malicious input
|
||||
String maliciousFilename = "malicious../../../etc/passwd";
|
||||
|
||||
// when - process input
|
||||
processFile(maliciousFilename);
|
||||
|
||||
// then - verify security measures
|
||||
assertThat(tempFile.getParent()).isEqualTo(saveDir);
|
||||
assertThat(tempFile.getName()).doesNotContain("..");
|
||||
}
|
||||
```
|
||||
|
||||
### Reflection-Based Testing for Private Members
|
||||
```java
|
||||
Field privateField = ClassName.class.getDeclaredField("fieldName");
|
||||
privateField.setAccessible(true);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Type> values = (List<Type>) privateField.get(instance);
|
||||
```
|
||||
|
||||
## JavaDoc Documentation Standards
|
||||
|
||||
### Class-Level Documentation
|
||||
```java
|
||||
/**
|
||||
* Brief description of the class purpose and functionality.
|
||||
*
|
||||
* <p>Detailed description with multiple paragraphs explaining:</p>
|
||||
* <ul>
|
||||
* <li>Key features and capabilities</li>
|
||||
* <li>Security considerations</li>
|
||||
* <li>Resource management approach</li>
|
||||
* <li>Usage patterns and examples</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Usage example:</p>
|
||||
* <pre>
|
||||
* ClassName instance = new ClassName();
|
||||
* try {
|
||||
* instance.process(data);
|
||||
* } finally {
|
||||
* instance.cleanUp(); // Always clean up resources
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @see RelatedClass
|
||||
* @see org.apache.package.ImportantInterface
|
||||
*/
|
||||
```
|
||||
|
||||
### Method-Level Documentation
|
||||
```java
|
||||
/**
|
||||
* Brief description of what the method does.
|
||||
*
|
||||
* <p>Detailed description explaining:</p>
|
||||
* <ol>
|
||||
* <li>Step-by-step process</li>
|
||||
* <li>Security considerations</li>
|
||||
* <li>Error handling behavior</li>
|
||||
* <li>Resource management</li>
|
||||
* </ol>
|
||||
*
|
||||
* <p>Security note: This method creates files in controlled directory
|
||||
* to prevent security vulnerabilities.</p>
|
||||
*
|
||||
* @param paramName description of parameter and constraints
|
||||
* @param saveDir the directory where files will be created (must exist)
|
||||
* @return description of return value
|
||||
* @throws IOException if file creation fails or I/O error occurs
|
||||
* @see #relatedMethod(Type)
|
||||
* @see #cleanUpMethod()
|
||||
*/
|
||||
```
|
||||
|
||||
### Documentation Best Practices
|
||||
- **Always document security implications** in methods handling files/user input
|
||||
- **Include usage examples** for complex methods and classes
|
||||
- **Document exception conditions** and error handling behavior
|
||||
- **Reference related methods** using `@see` tags
|
||||
- **Explain resource management** responsibilities
|
||||
- **Use `<p>`, `<ol>`, `<ul>`, `<li>` for structured content
|
||||
- **Include `<pre>` blocks** for code examples
|
||||
|
||||
## Error Handling & Logging
|
||||
|
||||
### Error Message Patterns
|
||||
```java
|
||||
// Localized error messages
|
||||
LocalizedMessage errorMessage = buildErrorMessage(
|
||||
e.getClass(),
|
||||
e.getMessage(),
|
||||
new Object[]{fileName}
|
||||
);
|
||||
if (!errors.contains(errorMessage)) {
|
||||
errors.add(errorMessage);
|
||||
}
|
||||
```
|
||||
|
||||
### Logging Best Practices
|
||||
```java
|
||||
// Use parameterized logging for performance
|
||||
LOG.debug("Processing file: {} in directory: {}",
|
||||
normalizeSpace(fileName), saveDir);
|
||||
|
||||
// Log security-relevant operations
|
||||
LOG.warn("Failed to delete temporary file: {}", tempFile.getAbsolutePath());
|
||||
|
||||
// Use appropriate log levels
|
||||
LOG.debug() // Development details
|
||||
LOG.info() // General information
|
||||
LOG.warn() // Potential issues
|
||||
LOG.error() // Serious problems
|
||||
```
|
||||
|
||||
## Code Quality Standards
|
||||
|
||||
### Method Scope & Extensibility
|
||||
- Use `protected` for methods that subclasses might override
|
||||
- Implement cleanup methods as separate `protected` methods
|
||||
- Make core functionality extensible while maintaining security
|
||||
|
||||
### Exception Handling
|
||||
- Catch specific exceptions rather than generic `Exception`
|
||||
- Log exceptions with context but continue cleanup operations
|
||||
- Use try-finally blocks to ensure cleanup always occurs
|
||||
|
||||
### Code Organization
|
||||
- Group related methods together (processing, cleanup, utilities)
|
||||
- Keep security-critical code in dedicated methods
|
||||
- Use clear, descriptive method and variable names
|
||||
- Follow existing project conventions and patterns
|
||||
|
||||
## Common Pitfalls to Avoid
|
||||
|
||||
1. **File Security**: Never use `File.createTempFile()` without directory control
|
||||
2. **Resource Leaks**: Always track and clean up temporary files
|
||||
3. **Test Coverage**: Don't forget to test error conditions and cleanup
|
||||
4. **Documentation**: Always document security implications
|
||||
5. **Exception Handling**: Don't let cleanup failures affect main operations
|
||||
6. **Path Validation**: Always validate and sanitize file paths
|
||||
7. **Reflection Testing**: Use `@SuppressWarnings("unchecked")` appropriately
|
||||
|
||||
This document should be updated as new patterns and practices emerge during development.
|
||||
Vendored
+51
-18
@@ -39,7 +39,7 @@ pipeline {
|
||||
stages {
|
||||
stage('Test') {
|
||||
steps {
|
||||
sh './mvnw -B -DskipAssembly verify'
|
||||
sh './mvnw -B -DskipAssembly verify --no-transfer-progress'
|
||||
}
|
||||
post {
|
||||
always {
|
||||
@@ -64,15 +64,10 @@ pipeline {
|
||||
maven 'maven_3_latest'
|
||||
}
|
||||
environment {
|
||||
MAVEN_OPTS = "-Xmx2048m"
|
||||
MAVEN_OPTS = "-Xmx1024m"
|
||||
}
|
||||
stages {
|
||||
stage('Install') {
|
||||
steps {
|
||||
sh './mvnw -B install -DskipTests -DskipAssembly'
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
stage('Test & Coverage') {
|
||||
steps {
|
||||
sh './mvnw -B verify -Pcoverage -DskipAssembly'
|
||||
}
|
||||
@@ -83,13 +78,57 @@ pipeline {
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build Source & JavaDoc') {
|
||||
stage('Code Quality') {
|
||||
when {
|
||||
anyOf {
|
||||
branch 'main'
|
||||
branch 'release/struts-6-7-x'
|
||||
}
|
||||
}
|
||||
steps {
|
||||
withCredentials([string(credentialsId: 'asf-struts-sonarcloud', variable: 'SONARCLOUD_TOKEN')]) {
|
||||
sh './mvnw -B -Pcoverage -DskipAssembly -Dsonar.login=${SONARCLOUD_TOKEN} verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
cleanWs deleteDirs: true, patterns: [[pattern: '**/target/**', type: 'INCLUDE']]
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('JDK 8') {
|
||||
agent {
|
||||
label 'ubuntu'
|
||||
}
|
||||
tools {
|
||||
jdk 'jdk_1.8_latest'
|
||||
maven 'maven_3_latest'
|
||||
}
|
||||
environment {
|
||||
MAVEN_OPTS = "-Xmx1024m"
|
||||
}
|
||||
stages {
|
||||
stage('Build') {
|
||||
steps {
|
||||
sh './mvnw -B clean install -DskipTests -DskipAssembly'
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
steps {
|
||||
sh './mvnw -B verify -DskipAssembly'
|
||||
}
|
||||
post {
|
||||
always {
|
||||
junit(testResults: '**/surefire-reports/*.xml', allowEmptyResults: true)
|
||||
junit(testResults: '**/failsafe-reports/*.xml', allowEmptyResults: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Build Source & JavaDoc') {
|
||||
when {
|
||||
branch 'release/struts-6-7-x'
|
||||
}
|
||||
steps {
|
||||
dir("local-snapshots-dir/") {
|
||||
deleteDir()
|
||||
@@ -99,10 +138,7 @@ pipeline {
|
||||
}
|
||||
stage('Deploy Snapshot') {
|
||||
when {
|
||||
anyOf {
|
||||
branch 'main'
|
||||
branch 'release/struts-6-7-x'
|
||||
}
|
||||
branch 'release/struts-6-7-x'
|
||||
}
|
||||
steps {
|
||||
withCredentials([file(credentialsId: 'lukaszlenart-repository-access-token', variable: 'CUSTOM_SETTINGS')]) {
|
||||
@@ -112,10 +148,7 @@ pipeline {
|
||||
}
|
||||
stage('Upload nightlies') {
|
||||
when {
|
||||
anyOf {
|
||||
branch 'main'
|
||||
branch 'release/struts-6-7-x'
|
||||
}
|
||||
branch 'release/struts-6-7-x'
|
||||
}
|
||||
steps {
|
||||
sh './mvnw -B package -DskipTests'
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
The Apache Struts web framework
|
||||
-------------------------------
|
||||
|
||||
[](https://ci-builds.apache.org/job/Struts/job/Struts%20Core/job/main/)
|
||||
[](https://ci-builds.apache.org/job/Struts/job/Struts%20Core/job/master/)
|
||||
[](https://github.com/apache/struts/actions/workflows/maven.yml)
|
||||
[](https://maven-badges.sml.io/maven-central/org.apache.struts/struts2-core/)
|
||||
[](https://maven-badges.herokuapp.com/maven-central/org.apache.struts/struts2-core/)
|
||||
[](https://javadoc.io/doc/org.apache.struts/struts2-core)
|
||||
[](https://sonarcloud.io/summary/new_code?id=apache_struts)
|
||||
[](https://deps.dev/maven/org.apache.struts%3Astruts2-core)
|
||||
@@ -103,15 +103,8 @@ the Struts approach.
|
||||
|
||||
## Commercial Support
|
||||
|
||||
The Apache Struts community does not offer commercial support by itself, but we maintain [a list of companies offering
|
||||
commercial support on our website](https://struts.apache.org/commercial-support.html).
|
||||
The Apache Struts community does not offer commercial support by itself.
|
||||
|
||||
Some Apache Struts maintainers are working with [Tidelift](https://tidelift.com/) to provide commercial support and
|
||||
invest paid working time in the improvement of the Apache Struts framework. For more information, visit
|
||||
the [Tidelift resources regarding Apache Struts](https://tidelift.com/subscription/pkg/maven-org-apache-struts-struts2-core?utm_source=maven-org-apache-struts-struts2-core&utm_medium=referral&utm_campaign=readme)
|
||||
|
||||
## Thank you
|
||||
|
||||
[YourKit](https://www.yourkit.com/) is kindly supporting open source projects with its full-featured Java Profiler.
|
||||
YourKit is the creator of innovative and intelligent tools for profiling Java and .NET applications.
|
||||
As an Apache committer, you can get a free license at [YourKit's open source sponsorship program](https://www.yourkit.com/java/profiler/purchase/#os_license).
|
||||
|
||||
+2
-3
@@ -7,9 +7,8 @@ and what potential vulnerability it can have:
|
||||
|
||||
| Version | Supported |
|
||||
|---------|--------------------|
|
||||
| 7.x | :white_check_mark: |
|
||||
| 6.7.x | :white_check_mark: |
|
||||
| 2.5.x | ❌ |
|
||||
| 6.x | :white_check_mark: |
|
||||
| 2.5.x | :white_check_mark: |
|
||||
|
||||
## Reporting New Security Issues with thr Apache Struts
|
||||
|
||||
|
||||
+4
-2
@@ -24,8 +24,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-parent</artifactId>
|
||||
<version>7.1.0</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
<version>6.7.2</version>
|
||||
</parent>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
@@ -94,10 +93,13 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${spring.platformVersion}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -24,12 +24,12 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>7.1.0</version>
|
||||
<version>6.7.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-rest-showcase</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>7.1.0</version>
|
||||
<version>6.7.2</version>
|
||||
<name>Struts 2 Rest Showcase Webapp</name>
|
||||
<description>Struts 2 Rest Showcase Example</description>
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.htmlunit</groupId>
|
||||
<groupId>net.sourceforge.htmlunit</groupId>
|
||||
<artifactId>htmlunit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
@@ -107,7 +107,7 @@
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>11.0.26</version>
|
||||
<version>9.4.46.v20220331</version>
|
||||
<configuration>
|
||||
<stopKey>CTRL+C</stopKey>
|
||||
<stopPort>8999</stopPort>
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
*/
|
||||
package org.demo.rest.example;
|
||||
|
||||
import org.apache.struts2.ModelDriven;
|
||||
import org.apache.struts2.Validateable;
|
||||
import org.apache.struts2.ValidationAwareSupport;
|
||||
import com.opensymphony.xwork2.ModelDriven;
|
||||
import com.opensymphony.xwork2.Validateable;
|
||||
import com.opensymphony.xwork2.ValidationAwareSupport;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.convention.annotation.Result;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="com.opensymphony.xwork2" level="info"/>
|
||||
<Logger name="org.apache.struts2" level="info"/>
|
||||
<Logger name="org.demo.rest" level="debug"/>
|
||||
<Root level="warn">
|
||||
|
||||
+3
-13
@@ -18,41 +18,31 @@
|
||||
*/
|
||||
package it.org.apache.struts2.rest.example;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import net.sourceforge.jwebunit.junit.WebTestCase;
|
||||
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.assertTextNotPresent;
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.assertTextPresent;
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.beginAt;
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.getTestContext;
|
||||
public class GetOrdersTest extends WebTestCase {
|
||||
|
||||
public class GetOrdersTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
getTestContext().setBaseUrl(ParameterUtils.getBaseUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
public void testGetOrders() {
|
||||
beginAt("/orders/3");
|
||||
assertTextPresent("Bob");
|
||||
assertTextNotPresent("Sarah");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOrdersInHtml() {
|
||||
beginAt("/orders/3.xhtml");
|
||||
assertTextPresent("Bob");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOrdersInXml() {
|
||||
beginAt("/orders/3.xml");
|
||||
assertTextPresent("<clientName>Bob");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOrdersInJson() {
|
||||
beginAt("/orders/3.json");
|
||||
assertTextPresent("\"clientName\":\"Bob\"");
|
||||
|
||||
+3
-12
@@ -18,21 +18,15 @@
|
||||
*/
|
||||
package it.org.apache.struts2.rest.example;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import net.sourceforge.jwebunit.junit.WebTestCase;
|
||||
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.assertTextPresent;
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.beginAt;
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.getTestContext;
|
||||
public class ListOrdersTest extends WebTestCase {
|
||||
|
||||
public class ListOrdersTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
getTestContext().setBaseUrl(ParameterUtils.getBaseUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
public void testListOrders() {
|
||||
beginAt("/orders");
|
||||
assertTextPresent("Bob");
|
||||
@@ -40,7 +34,6 @@ public class ListOrdersTest {
|
||||
assertTextPresent("Jim");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListOrdersInHtml() {
|
||||
beginAt("/orders.xhtml");
|
||||
assertTextPresent("Bob");
|
||||
@@ -48,7 +41,6 @@ public class ListOrdersTest {
|
||||
assertTextPresent("Jim");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListOrdersInXml() {
|
||||
beginAt("/orders.xml");
|
||||
assertTextPresent("<clientName>Bob");
|
||||
@@ -56,7 +48,6 @@ public class ListOrdersTest {
|
||||
assertTextPresent("<clientName>Jim");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListOrdersInJson() {
|
||||
beginAt("/orders.json");
|
||||
assertTextPresent("\"clientName\":\"Bob\"");
|
||||
|
||||
+4
-24
@@ -18,37 +18,23 @@
|
||||
*/
|
||||
package it.org.apache.struts2.rest.example;
|
||||
|
||||
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
|
||||
import net.sourceforge.jwebunit.junit.WebTestCase;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.htmlunit.FailingHttpStatusCodeException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.assertLinkNotPresentWithText;
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.assertTextFieldEquals;
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.assertTextPresent;
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.beginAt;
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.getTestContext;
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.setTextField;
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.setWorkingForm;
|
||||
import static net.sourceforge.jwebunit.junit.JWebUnit.submit;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
public class PostOrderTest extends WebTestCase {
|
||||
|
||||
public class PostOrderTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
getTestContext().setBaseUrl(ParameterUtils.getBaseUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
public void testPostOrder() {
|
||||
beginAt("/orders/new");
|
||||
setWorkingForm(0);
|
||||
@@ -59,7 +45,6 @@ public class PostOrderTest {
|
||||
assertLinkNotPresentWithText("Back to Orders");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostOrderWithErrors() {
|
||||
beginAt("/orders/new");
|
||||
setWorkingForm(0);
|
||||
@@ -73,7 +58,6 @@ public class PostOrderTest {
|
||||
assertTextFieldEquals("amount", "321");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostOrderInHtml() {
|
||||
beginAt("/orders/new.xhtml");
|
||||
setWorkingForm(0);
|
||||
@@ -88,7 +72,6 @@ public class PostOrderTest {
|
||||
assertLinkNotPresentWithText("Back to Orders");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostOrderInXml() throws IOException {
|
||||
CloseableHttpClient client = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(ParameterUtils.getBaseUrl() + "/orders.xml");
|
||||
@@ -102,7 +85,6 @@ public class PostOrderTest {
|
||||
client.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostOrderInXmlWithBadData() throws IOException {
|
||||
CloseableHttpClient client = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(ParameterUtils.getBaseUrl() + "/orders.xml");
|
||||
@@ -116,7 +98,6 @@ public class PostOrderTest {
|
||||
client.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostOrderInJson() throws IOException {
|
||||
CloseableHttpClient client = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(ParameterUtils.getBaseUrl() + "/orders.json");
|
||||
@@ -127,7 +108,6 @@ public class PostOrderTest {
|
||||
client.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostOrderInJsonWithBadData() throws IOException {
|
||||
CloseableHttpClient client = HttpClients.createDefault();
|
||||
HttpPost httpPost = new HttpPost(ParameterUtils.getBaseUrl() + "/orders.json");
|
||||
|
||||
+31
-78
@@ -24,7 +24,7 @@
|
||||
<parent>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-apps</artifactId>
|
||||
<version>7.1.0</version>
|
||||
<version>6.7.2</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>struts2-showcase</artifactId>
|
||||
@@ -48,11 +48,21 @@
|
||||
<artifactId>struts2-config-browser-plugin</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-sitemesh-plugin</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-tiles-plugin</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-dwr-plugin</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-json-plugin</artifactId>
|
||||
@@ -82,14 +92,6 @@
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-velocity-plugin</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-velocity-tools-view-jakarta</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-velocity-tools-jsp-jakarta</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
@@ -97,8 +99,8 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>jakarta.servlet</groupId>
|
||||
<artifactId>jakarta.servlet-api</artifactId>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -121,9 +123,12 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.sitemesh</groupId>
|
||||
<artifactId>sitemesh</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<groupId>opensymphony</groupId>
|
||||
<artifactId>sitemesh</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.directwebremoting</groupId>
|
||||
<artifactId>dwr</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
@@ -139,75 +144,26 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.htmlunit</groupId>
|
||||
<artifactId>htmlunit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<groupId>net.sourceforge.htmlunit</groupId>
|
||||
<artifactId>htmlunit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- BeanValidation Example -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>${hibernate-validator.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
Nashorn (the built-in JDK javascript engine) was deprecated in JDK 11 and removed in JDK 15
|
||||
As a result attempting to use @ScriptAssert on JDK 17 leads to the exception
|
||||
See more details
|
||||
https://stackoverflow.com/questions/78008950/resolve-org-hibernate-validator-spi-scripting-scriptevaluatornotfoundexception
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-jsr223</artifactId>
|
||||
<version>3.0.22</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<?m2e ignore?>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/extraclasspath</outputDirectory>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-velocity-tools-view-jakarta</artifactId>
|
||||
<destFileName>struts2-velocity-tools-view-jakarta.jar</destFileName>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.apache.struts</groupId>
|
||||
<artifactId>struts2-velocity-tools-jsp-jakarta</artifactId>
|
||||
<destFileName>struts2-velocity-tools-jsp-jakarta.jar</destFileName>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
<overWriteReleases>false</overWriteReleases>
|
||||
<overWriteSnapshots>false</overWriteSnapshots>
|
||||
<overWriteIfNewer>true</overWriteIfNewer>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>3.5.3</version>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>it.org.apache.struts2.showcase.*Test</include>
|
||||
@@ -234,7 +190,7 @@
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>11.0.26</version>
|
||||
<version>9.4.46.v20220331</version>
|
||||
<configuration>
|
||||
<stopKey>CTRL+C</stopKey>
|
||||
<stopPort>8999</stopPort>
|
||||
@@ -247,15 +203,12 @@
|
||||
<httpConnector>
|
||||
<port>8090</port>
|
||||
</httpConnector>
|
||||
<scan>10</scan>
|
||||
<webApp>
|
||||
<extraClasspath>
|
||||
${project.build.directory}/extraclasspath/struts2-velocity-tools-view-jakarta.jar,
|
||||
${project.build.directory}/extraclasspath/struts2-velocity-tools-jsp-jakarta
|
||||
</extraClasspath>
|
||||
<contextPath>/struts2-showcase</contextPath>
|
||||
<descriptor>${basedir}/src/main/webapp/WEB-INF/web.xml</descriptor>
|
||||
</webApp>
|
||||
<scanIntervalSeconds>10</scanIntervalSeconds>
|
||||
<webAppSourceDirectory>${basedir}/src/main/webapp/</webAppSourceDirectory>
|
||||
<webAppConfig>
|
||||
<contextPath>/struts2-showcase</contextPath>
|
||||
<descriptor>${basedir}/src/main/webapp/WEB-INF/web.xml</descriptor>
|
||||
</webAppConfig>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Calendar;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
import org.apache.struts2.showcase.ajax.tree.Category;
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
import org.apache.struts2.showcase.ajax.tree.Category;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.showcase.ajax.tree.Category;
|
||||
|
||||
// START SNIPPET: treeExampleDynamicJavaShow
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import org.apache.struts2.Validateable;
|
||||
import org.apache.struts2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.Validateable;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.action;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.action;
|
||||
|
||||
import org.apache.struts2.Preparable;
|
||||
import com.opensymphony.xwork2.Preparable;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.action;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.action;
|
||||
|
||||
import org.apache.struts2.action.Action;
|
||||
import org.apache.struts2.interceptor.annotations.After;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.interceptor.annotations.After;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.action;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
import org.apache.struts2.showcase.model.MyDto;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.action;
|
||||
|
||||
import org.apache.struts2.Preparable;
|
||||
import com.opensymphony.xwork2.Preparable;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.actionchaining;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
public class ActionChain1 extends ActionSupport {
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.actionchaining;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
public class ActionChain2 extends ActionSupport {
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.actionchaining;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
public class ActionChain3 extends ActionSupport {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.ajax;
|
||||
|
||||
import org.apache.struts2.action.Action;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.ajax;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.ajax;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.ajax;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
public class Example5Action extends ActionSupport {
|
||||
|
||||
@@ -46,7 +46,8 @@ public class Category {
|
||||
new Category(15, "Dojo"),
|
||||
new Category(16, "Prototype"),
|
||||
new Category(17, "Scriptaculous"),
|
||||
new Category(18, "OpenRico")));
|
||||
new Category(18, "OpenRico"),
|
||||
new Category(19, "DWR")));
|
||||
}
|
||||
|
||||
public static Category getById(long id) {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.ajax.tree;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
|
||||
+60
-63
@@ -31,10 +31,9 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TestDataProvider.
|
||||
@@ -42,76 +41,74 @@ import java.util.List;
|
||||
@Service
|
||||
public class TestDataProvider implements Serializable, InitializingBean {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger log = LogManager.getLogger(TestDataProvider.class);
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger log = LogManager.getLogger(TestDataProvider.class);
|
||||
|
||||
public static final String[] POSITIONS = {
|
||||
"Developer",
|
||||
"System Architect",
|
||||
"Sales Manager",
|
||||
"CEO"
|
||||
};
|
||||
public static final String[] POSITIONS = {
|
||||
"Developer",
|
||||
"System Architect",
|
||||
"Sales Manager",
|
||||
"CEO"
|
||||
};
|
||||
|
||||
public static final String[] LEVELS = {
|
||||
"Junior",
|
||||
"Senior",
|
||||
"Master"
|
||||
};
|
||||
public static final String[] LEVELS = {
|
||||
"Junior",
|
||||
"Senior",
|
||||
"Master"
|
||||
};
|
||||
|
||||
private static final Skill[] TEST_SKILLS = {
|
||||
new Skill("WW-SEN", "Struts Senior Developer"),
|
||||
new Skill("WW-JUN", "Struts Junior Developer"),
|
||||
new Skill("SPRING-DEV", "Spring Developer")
|
||||
};
|
||||
private static final Skill[] TEST_SKILLS = {
|
||||
new Skill("WW-SEN", "Struts Senior Developer"),
|
||||
new Skill("WW-JUN", "Struts Junior Developer"),
|
||||
new Skill("SPRING-DEV", "Spring Developer")
|
||||
};
|
||||
|
||||
public static final Employee[] TEST_EMPLOYEES = {
|
||||
new Employee(1L, "Alan", "Smithee", new Date(), 2000f, true, POSITIONS[0],
|
||||
TEST_SKILLS[0], null, "alan", LEVELS[0], "Nice guy"),
|
||||
new Employee(2L, "Robert", "Robson", new Date(), 10000f, false, POSITIONS[1],
|
||||
TEST_SKILLS[1], List.of(TEST_SKILLS).subList(1, TEST_SKILLS.length), "rob", LEVELS[1], "Smart guy")
|
||||
};
|
||||
public static final Employee[] TEST_EMPLOYEES = {
|
||||
new Employee(new Long(1), "Alan", "Smithee", new Date(), new Float(2000f), true, POSITIONS[0],
|
||||
TEST_SKILLS[0], null, "alan", LEVELS[0], "Nice guy"),
|
||||
new Employee(new Long(2), "Robert", "Robson", new Date(), new Float(10000f), false, POSITIONS[1],
|
||||
TEST_SKILLS[1], Arrays.asList(TEST_SKILLS).subList(1, TEST_SKILLS.length), "rob", LEVELS[1], "Smart guy")
|
||||
};
|
||||
|
||||
@Autowired
|
||||
private SkillDao skillDao;
|
||||
@Autowired
|
||||
private SkillDao skillDao;
|
||||
|
||||
@Autowired
|
||||
private EmployeeDao employeeDao;
|
||||
@Autowired
|
||||
private EmployeeDao employeeDao;
|
||||
|
||||
protected void addTestSkills() {
|
||||
try {
|
||||
for (Skill testSkill : TEST_SKILLS) {
|
||||
skillDao.merge(testSkill);
|
||||
}
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("TestDataProvider - [addTestSkills]: Added test skill data.");
|
||||
}
|
||||
} catch (StorageException e) {
|
||||
log.error("TestDataProvider - [addTestSkills]: Exception caught: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
protected void addTestSkills() {
|
||||
try {
|
||||
for (int i = 0, j = TEST_SKILLS.length; i < j; i++) {
|
||||
skillDao.merge(TEST_SKILLS[i]);
|
||||
}
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("TestDataProvider - [addTestSkills]: Added test skill data.");
|
||||
}
|
||||
} catch (StorageException e) {
|
||||
log.error("TestDataProvider - [addTestSkills]: Exception catched: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void addTestEmployees() {
|
||||
try {
|
||||
for (Employee testEmployee : TEST_EMPLOYEES) {
|
||||
employeeDao.merge(testEmployee);
|
||||
}
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("TestDataProvider - [addTestEmployees]: Added test employee data.");
|
||||
}
|
||||
} catch (StorageException e) {
|
||||
log.error("TestDataProvider - [addTestEmployees]: Exception caught: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
protected void addTestEmployees() {
|
||||
try {
|
||||
for (int i = 0, j = TEST_EMPLOYEES.length; i < j; i++) {
|
||||
employeeDao.merge(TEST_EMPLOYEES[i]);
|
||||
}
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("TestDataProvider - [addTestEmployees]: Added test employee data.");
|
||||
}
|
||||
} catch (StorageException e) {
|
||||
log.error("TestDataProvider - [addTestEmployees]: Exception catched: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected void addTestData() {
|
||||
addTestSkills();
|
||||
addTestEmployees();
|
||||
}
|
||||
protected void addTestData() {
|
||||
addTestSkills();
|
||||
addTestEmployees();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
addTestData();
|
||||
}
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
addTestData();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.async;
|
||||
|
||||
import jakarta.servlet.Filter;
|
||||
import jakarta.servlet.FilterChain;
|
||||
import jakarta.servlet.FilterConfig;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.async;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
+4
-4
@@ -21,10 +21,10 @@
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
|
||||
import org.apache.struts2.action.Action;
|
||||
import org.apache.struts2.ActionContext;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.interceptor.AbstractInterceptor;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import org.apache.struts2.action.Action;
|
||||
import org.apache.struts2.ActionContext;
|
||||
import org.apache.struts2.ActionInvocation;
|
||||
import org.apache.struts2.interceptor.AbstractInterceptor;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionInvocation;
|
||||
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
+3
-3
@@ -25,9 +25,9 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import jakarta.servlet.http.HttpSessionEvent;
|
||||
import jakarta.servlet.http.HttpSessionListener;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpSessionEvent;
|
||||
import javax.servlet.http.HttpSessionListener;
|
||||
|
||||
public class ChatSessionListener implements HttpSessionListener {
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
public class CrudRoomAction extends ActionSupport {
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import org.apache.struts2.conversion.impl.XWorkConverter;
|
||||
import org.apache.struts2.inject.Inject;
|
||||
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
|
||||
import com.opensymphony.xwork2.inject.Inject;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.struts2.util.StrutsTypeConverter;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.chat;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.conversion;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.conversion;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.conversion;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.filedownload;
|
||||
|
||||
import org.apache.struts2.action.Action;
|
||||
import com.opensymphony.xwork2.Action;
|
||||
import org.apache.struts2.ServletActionContext;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.fileupload;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.action.UploadedFilesAware;
|
||||
import org.apache.struts2.dispatcher.multipart.UploadedFile;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
// START SNIPPET: entire-file
|
||||
package org.apache.struts2.showcase.fileupload;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.action.UploadedFilesAware;
|
||||
import org.apache.struts2.dispatcher.multipart.UploadedFile;
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
// START SNIPPET: entire-file
|
||||
package org.apache.struts2.showcase.fileupload;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.action.UploadedFilesAware;
|
||||
import org.apache.struts2.dispatcher.multipart.UploadedFile;
|
||||
|
||||
|
||||
+3
-3
@@ -20,12 +20,12 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.freemarker;
|
||||
|
||||
import org.apache.struts2.util.ValueStack;
|
||||
import com.opensymphony.xwork2.util.ValueStack;
|
||||
import org.apache.struts2.views.freemarker.FreemarkerManager;
|
||||
import org.apache.struts2.views.freemarker.ScopesHashModel;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.freemarker;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import org.apache.struts2.Preparable;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.Preparable;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.text.DateFormatSymbols;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.hangman;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.hangman;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.action.SessionAware;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
|
||||
@@ -20,34 +20,40 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.hangman;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Hangman implements Serializable {
|
||||
|
||||
private static final Logger log = LogManager.getLogger(Hangman.class);
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 8566954355839652509L;
|
||||
|
||||
private final Vocab vocab;
|
||||
private Vocab vocab;
|
||||
|
||||
private Boolean win = false;
|
||||
|
||||
private int guessLeft = 5;
|
||||
public final List<Character> charactersAvailable;
|
||||
public List<Character> charactersAvailable;
|
||||
public List<Character> charactersGuessed;
|
||||
|
||||
public Hangman(Vocab vocab) {
|
||||
charactersAvailable = new ArrayList<>(List.of(
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
||||
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'));
|
||||
charactersGuessed = new ArrayList<>();
|
||||
// Arrays.asList(...) returns List that doesn't support remove(), hence
|
||||
// we wrap it with an ArrayList to avoid UnsupportedOperationException
|
||||
// when doing a remove()
|
||||
charactersAvailable = new ArrayList<Character>(Arrays.asList(
|
||||
new Character[]{
|
||||
Character.valueOf('A'), Character.valueOf('B'), Character.valueOf('C'),
|
||||
Character.valueOf('D'), Character.valueOf('E'), Character.valueOf('F'),
|
||||
Character.valueOf('G'), Character.valueOf('H'), Character.valueOf('I'),
|
||||
Character.valueOf('J'), Character.valueOf('K'), Character.valueOf('L'),
|
||||
Character.valueOf('M'), Character.valueOf('N'), Character.valueOf('O'),
|
||||
Character.valueOf('P'), Character.valueOf('Q'), Character.valueOf('R'),
|
||||
Character.valueOf('S'), Character.valueOf('T'), Character.valueOf('U'),
|
||||
Character.valueOf('V'), Character.valueOf('W'), Character.valueOf('X'),
|
||||
Character.valueOf('Y'), Character.valueOf('Z')
|
||||
}));
|
||||
charactersGuessed = new ArrayList<Character>();
|
||||
this.vocab = vocab;
|
||||
}
|
||||
|
||||
@@ -69,8 +75,8 @@ public class Hangman implements Serializable {
|
||||
}
|
||||
if (vocab.containsAllCharacter(charactersGuessed)) {
|
||||
win = true;
|
||||
log.info("Game won");
|
||||
}
|
||||
System.out.println(" *********************************** " + win);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +98,7 @@ public class Hangman implements Serializable {
|
||||
|
||||
public List<Character> getCharactersAvailable() {
|
||||
synchronized (charactersAvailable) {
|
||||
return new ArrayList<>(charactersAvailable);
|
||||
return new ArrayList<Character>(charactersAvailable);
|
||||
//return charactersAvailable;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.hangman;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -20,19 +20,17 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.hangman;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class Vocab implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final String vocab;
|
||||
private final String hint;
|
||||
private String vocab;
|
||||
private String hint;
|
||||
private Character[] characters; // character this vocab is made up of
|
||||
|
||||
public Vocab(String vocab, String hint) {
|
||||
@@ -54,7 +52,7 @@ public class Vocab implements Serializable {
|
||||
public Boolean containCharacter(Character character) {
|
||||
assert (character != null);
|
||||
|
||||
return vocab.contains(character.toString());
|
||||
return (vocab.contains(character.toString())) ? true : false;
|
||||
}
|
||||
|
||||
public Character[] inCharacters() {
|
||||
@@ -62,21 +60,32 @@ public class Vocab implements Serializable {
|
||||
char[] c = vocab.toCharArray();
|
||||
characters = new Character[c.length];
|
||||
for (int a = 0; a < c.length; a++) {
|
||||
characters[a] = c[a];
|
||||
characters[a] = Character.valueOf(c[a]);
|
||||
}
|
||||
}
|
||||
return characters;
|
||||
}
|
||||
|
||||
public boolean containsAllCharacter(List<Character> charactersGuessed) {
|
||||
return new HashSet<>(charactersGuessed).containsAll(Arrays.asList(inCharacters()));
|
||||
Character[] chars = inCharacters();
|
||||
List<Character> tmpChars = Arrays.asList(chars);
|
||||
return charactersGuessed.containsAll(tmpChars);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
public static void main(String args[]) throws Exception {
|
||||
Vocab v = new Vocab("JAVA", "a java word");
|
||||
|
||||
System.out.println(v.containsAllCharacter(List.of('J', 'V')));
|
||||
System.out.println(v.containsAllCharacter(List.of('J', 'V', 'A')));
|
||||
List<Character> list1 = new ArrayList<Character>();
|
||||
list1.add(new Character('J'));
|
||||
list1.add(new Character('V'));
|
||||
|
||||
List<Character> list2 = new ArrayList<Character>();
|
||||
list2.add(new Character('J'));
|
||||
list2.add(new Character('V'));
|
||||
list2.add(new Character('A'));
|
||||
|
||||
System.out.println(v.containsAllCharacter(list1));
|
||||
System.out.println(v.containsAllCharacter(list2));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.modelDriven;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import org.apache.struts2.ModelDriven;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ModelDriven;
|
||||
import org.apache.struts2.showcase.modelDriven.model.Gangster;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.person;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.convention.annotation.Result;
|
||||
import org.apache.struts2.convention.annotation.Results;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.person;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.convention.annotation.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.person;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.convention.annotation.Result;
|
||||
import org.apache.struts2.convention.annotation.Results;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.servlet;
|
||||
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
public class TestServlet extends HttpServlet {
|
||||
|
||||
+3
-3
@@ -20,12 +20,12 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.source;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import org.apache.struts2.util.ClassLoaderUtil;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.util.ClassLoaderUtil;
|
||||
import org.apache.struts2.action.ServletContextAware;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import jakarta.servlet.ServletContext;
|
||||
import javax.servlet.ServletContext;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.tag.nonui.actionPrefix;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
public class SubmitAction extends ActionSupport {
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.tag.nonui.actiontag;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.tag.nonui.debugtag;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.dispatcher.PrepareOperations;
|
||||
|
||||
public class DebugTagAction extends ActionSupport {
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.tag.nonui.iteratortag;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import org.apache.struts2.Validateable;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.Validateable;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.tag.nonui.iteratortag;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.tag.nonui.iteratortag;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import org.apache.struts2.Validateable;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.Validateable;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.tag.nonui.iteratortag;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import org.apache.struts2.Validateable;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import com.opensymphony.xwork2.Validateable;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.apache.struts2.convention.annotation.Result;
|
||||
import org.apache.struts2.tiles.annotation.TilesDefinition;
|
||||
import org.apache.struts2.tiles.annotation.TilesPutAttribute;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
@Namespace("/tiles")
|
||||
@ParentPackage("tiles")
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.token;
|
||||
|
||||
import org.apache.struts2.ActionContext;
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionContext;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.validation;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
||||
+9
-9
@@ -18,15 +18,15 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.validation;
|
||||
|
||||
import org.apache.struts2.validator.annotations.DateRangeFieldValidator;
|
||||
import org.apache.struts2.validator.annotations.EmailValidator;
|
||||
import org.apache.struts2.validator.annotations.FieldExpressionValidator;
|
||||
import org.apache.struts2.validator.annotations.IntRangeFieldValidator;
|
||||
import org.apache.struts2.validator.annotations.RegexFieldValidator;
|
||||
import org.apache.struts2.validator.annotations.RequiredFieldValidator;
|
||||
import org.apache.struts2.validator.annotations.RequiredStringValidator;
|
||||
import org.apache.struts2.validator.annotations.StringLengthFieldValidator;
|
||||
import org.apache.struts2.validator.annotations.UrlValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.DateRangeFieldValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.EmailValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.FieldExpressionValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.IntRangeFieldValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.RegexFieldValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.StringLengthFieldValidator;
|
||||
import com.opensymphony.xwork2.validator.annotations.UrlValidator;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
import java.sql.Date;
|
||||
|
||||
+8
-8
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.validation;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts.beanvalidation.constraints.FieldMatch;
|
||||
import org.apache.struts2.convention.annotation.Action;
|
||||
import org.apache.struts2.convention.annotation.Namespace;
|
||||
@@ -31,13 +31,13 @@ import org.apache.struts2.interceptor.validation.SkipValidation;
|
||||
import org.hibernate.validator.constraints.ScriptAssert;
|
||||
import org.hibernate.validator.constraints.URL;
|
||||
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Date;
|
||||
|
||||
// <!-- START SNIPPET: beanValidationExample -->
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.validation;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.validation;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.wait;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.interceptor.parameter.StrutsParameter;
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,12 +20,10 @@
|
||||
*/
|
||||
package org.apache.struts2.showcase.xslt;
|
||||
|
||||
import org.apache.struts2.ActionSupport;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.opensymphony.xwork2.ActionSupport;
|
||||
import org.apache.struts2.action.ServletRequestAware;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
@@ -30,5 +30,6 @@
|
||||
<AppenderRef ref="STDOUT"/>
|
||||
</Root>
|
||||
<Logger name="org.apache.struts2" level="info"/>
|
||||
<Logger name="com.opensymphony.xwork2" level="info"/>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
|
||||
@@ -21,6 +21,6 @@
|
||||
<div style="background-color:yellow;">
|
||||
<p>
|
||||
Freemarker Custom Template -
|
||||
parameter 'paramName' - ${attributes.paramName}
|
||||
parameter 'paramName' - ${parameters.paramName}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -24,9 +24,6 @@
|
||||
"https://struts.apache.org/dtds/struts-6.0.dtd">
|
||||
|
||||
<struts>
|
||||
|
||||
<constant name="struts.multipart.maxSize" value="10240" />
|
||||
|
||||
<package name="fileupload" extends="struts-default" namespace="/fileupload">
|
||||
|
||||
<action name="upload" class="org.apache.struts2.showcase.fileupload.FileUploadAction" method="input">
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user