Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 4 additions & 73 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,32 @@
<version>3.4.1</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.struts</groupId>
<groupId>com.example</groupId>
<artifactId>StrutsApp</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>StrutsApp</name>
<description>Struts application</description>
<url />
<licenses>
<license />
</licenses>
<developers>
<developer />
</developers>
<scm>
<connection />
<developerConnection />
<tag />
<url />
</scm>
<packaging>war</packaging>
<properties>
<java.version>21</java.version>
<spring-boot-admin.version>3.4.1</spring-boot-admin.version>
<spring-boot.version>3.4.1</spring-boot.version>
<struts.version>6.4.0</struts.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -70,62 +48,15 @@
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>${struts.version}</version>
</dependency>
<dependency>
<groupId>com.guicedee.services</groupId>
<artifactId>slf4j</artifactId>
<version>1.2.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.24.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.struts;
package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/com/example/action/HelloAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.example.action;

import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.ActionSupport;

public class HelloAction extends ActionSupport {
private static final long serialVersionUID = 1L;

private String message = "display hello struts based action";

/**
* @return the message
*/
public String getMessage() {
return message;
}

/**
* @param message the message to set
*/
public void setMessage(String message) {
this.message = message;
}

/**
* @return the serialversionuid
*/
public static long getSerialversionuid() {
return serialVersionUID;
}

@Override
public String execute() {
this.message = "view model is defined";
return SUCCESS;
}

public String displayResult() {
return "serial version is: " + getSerialversionuid() + " while message value is: " + getMessage();
}
}
25 changes: 25 additions & 0 deletions src/main/java/com/example/controller/HelloController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import com.example.action.HelloAction;

@Controller
public class HelloController {

/*
* @Autowired private HelloAction helloAction;
*
* public HelloController(HelloAction action) { this.helloAction = action; }
*/

@GetMapping("/view")
public String helloStruts() {
System.out.println("controller HelloController called sucessfully");

//this.helloAction.execute();

return "forward:/helloStruts";
}
}
29 changes: 29 additions & 0 deletions src/main/java/com/example/debugging/BeanDebugger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
*
*/
package com.example.debugging;

import java.util.Arrays;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BeanDebugger {

@Bean
public CommandLineRunner debugBeans(ApplicationContext ctx) {
return args -> {

System.out.println("Let's inspect the beans provided by Spring Boot:");

String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
System.out.println(beanName);
}

};
}
}
1 change: 1 addition & 0 deletions src/main/java/com/example/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package com.example;
22 changes: 0 additions & 22 deletions src/main/java/com/example/struts/HelloController.java

This file was deleted.

27 changes: 0 additions & 27 deletions src/main/java/com/example/struts/actions/HelloAction.java

This file was deleted.

3 changes: 2 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
spring.application.name=StrutsApp
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
server.port=8080
server.servlet.context-path=/hello
logging.level.web=debug
14 changes: 0 additions & 14 deletions src/main/resources/struts.xml

This file was deleted.

8 changes: 8 additions & 0 deletions src/main/webapp/WEB-INF/struts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<package name="default" namespace="/" extends="struts-default">
<action name="helloStruts" class="com.example.action.HelloAction">
<result name="success">/WEB-INF/views/view.jsp</result>
</action>
</package>
</struts>
10 changes: 10 additions & 0 deletions src/main/webapp/WEB-INF/views/view.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<title>Hello Struts</title>
</head>
<body>
<h1>Hello, Struts!</h1>
</body>
</html>
24 changes: 12 additions & 12 deletions src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
version="3.0">

<display-name>Struts demonstration</display-name>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<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>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>
17 changes: 0 additions & 17 deletions src/main/webapp/views/hello.jsp

This file was deleted.

Loading