Woody
Woody

Reputation: 97

How to add Struts 2 filter to a web application without web.xml?

Can someone help me with a minimal project setup using Spring Boot and Struts 2?

I have already created a Spring Boot application with a H2-database. I also added a h2Configuration class, so that I'm able to access the database with localhost:8080/console.

But, how can I add Struts 2 to my application without web.xml?

Upvotes: 1

Views: 2033

Answers (1)

Roman C
Roman C

Reputation: 1

Without web.xml you can only write a Struts2 filter using servlet 3.0 or higher

@WebFilter("/*")
public class Struts2Filter extends Struts2PrepareAndExecuteFilter {
}

The content could be empty, it's enough to add annotated filter without any inclusion in the web.xml file.

If you want to integrate Struts2 with Spring, then you should use a plugin.

Struts 2 provides a plugin that enables Spring to inject into the ActionSupport classes any dependent objects you've specified in the Spring configuration file. Consult Spring Plugin documentation for more information about how the plugin works.

Upvotes: 2

Related Questions