Spring Entering a Struts RequestProcessor request request

I wrote my own Struts RequsetProcessor tool for my application, which manually extracts some links from Spring. It works fine, but I would like to do the β€œright” thing and attach everything I need during construction.

Is there a way to define a custom Struts RequestProcessor so that I can insert Spring objects into it when Struts instantiates this RequestProcessor?

+4
source share
1 answer

The short answer is NO. Long answer "view":

Assuming that Struts is integrated with Spring in your application through ContextLoaderPlugin , you can do one of two things:

A) Create a "ProcessorContext" bean (or whatever you want to name) that you define in your Spring context and access your custom request processor by getting it from the Spring context (which you can go through WebApplicationContextUtils.getWebApplicationContext(getServletContext()) ).

B) If your user processor extends Spring DelegatingRequestProcessor or DelegatingTilesRequestProcessor , you can instead write a new request processor that does what you want functionally, bind it to the Spring context with all your dependencies, and then expand DelegatingRequestProcessor or DelegatingTilesRequestProcessor to get it out of context (via type or identifier) ​​and delegate it. This is essentially an extension (A), but it delegates all of the Spring plumbing to the Spring processor extension request, leaving your user processor Spring-independent.

Spring / Struts Integration is described in detail here .

+1
source

All Articles