struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jake Vang <>
Subject spring, struts2, convention plugin, how to "wire" an action class
Date Thu, 13 May 2010 09:22:38 GMT
i am using struts and the convention plugin. i am also using
spring for dependency injections (DI). my question is if it is
possible to to use struts2 + convention plugin with spring for DI on
my Action classes? i have searched  the internet but only seen
examples using struts 1 + spring for DI on Action classes. the
convention plugin makes life simpler (no XML), but also, partially
because of little documentation, makes it uneasy to do certain things.
i wonder if this is part of the reason why DI on Action classes using
spring + struts is not obvious for me.

Here's a simple code. This is my action class.

public class SpringWiringAction extends ActionSupport {
 private String message = "no dependency injection";

 public String springWiring() {
  return SUCCESS;

 public String getMessage() { return message; }
 public void setMessage(String message) { this.message = message; }

My "view" or the JSP page corresponding to the Action is:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<%@taglib uri="/struts-tags" prefix="s" %>
 <head><title>Test Spring Wiring</title</head>
 <s:property value="message"/>

My web.xml is setup according to

My spring XML file (/webapp/WEB-INF/applicationContext.xml) is defined
as following.

<bean id="placeholderConfig"
 <property name="location" value="WEB-INF/"/>
<bean name="/spring-wiring" class="">
 <property name="message" value="${message}"/>

My /webapp/WEB-INF/ file then has this content.

message=dependency inject success

when i start up tomcat 6, everything starts up correctly and there are
no complaints. however, when i go to
http://localhost/webapp/spring-wiring, the message that gets displayed
is "no dependency injection".

is there something that i am missing using spring + struts2 (with the
convention plugin) to use DI on Actions?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message