mvn archetype:generate -DgroupId=com.example -DartifactId=struts7-demo -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
cd struts7-demo
<dependencies>
<!-- Jakarta Struts Core -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>7.0.0</version>
</dependency>
<!-- Jakarta Servlet API -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<!-- Optional: JSON Plugin for REST Support -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>7.0.0</version>
</dependency>
<!-- Optional: Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.9</version>
</dependency>
</dependencies>
mvn clean install
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
version="6.0">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"https://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<package name="default" namespace="/" extends="struts-default">
<action name="hello" class="com.example.action.HelloAction">
<result name="success">/hello.jsp</result>
</action>
</package>
</struts>
package com.example.action;
import com.opensymphony.xwork2.ActionSupport;
public class HelloAction extends ActionSupport {
private String message;
public String execute() {
message = "Welcome to Jakarta Struts 7!";
return SUCCESS;
}
public String getMessage() {
return message;
}
}
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head><title>Struts 7 Demo</title></head>
<body>
<h1><s:property value="message"/></h1>
</body>
</html>
mvn package
http://localhost:8080/struts7-demo/hello
Conclusion Jakarta Struts 7 is configured similarly to previous versions, but it is now aligned with Jakarta EE 10. You need to use Jakarta Servlet 6.0+ and deploy on a compatible container like Tomcat 10+.