?????????д????Struts2???????????????????????????Struts2??Spring??Java?????
????????д??????????Struts2??Action????????????????????????????????
?????????????д????д??????£????????90?????
???????????????????????????????д???????У??????????????????
?????????????????????????-?????
????1.???????????????jar????
????struts.core??struts?????jar??
????spring-core-3.2.0.RELEASE.jar
?????????????????Щ?????翴??????????????Struts2?????Spring?????????
??????????????????java.lang.NoClassDefFoundError: org/springframework/core/io/ResourceLoader??
????spring-test-3.2.3.RELEASE.jar
????Junit??jar??
????Tomcat??Server Rumtime lib??
????2.???Action??

public class UserAction {
public String list(){
return "success";
}
}

??3.???????????

package unittest;
import org.apache.struts2.StrutsTestCase;
import org.junit.Test;
import action.UserAction;
import com.opensymphony.xwork2.ActionProxy;
public class ActionUnitTest extends StrutsTestCase {
// ??д????????????????????????
protected String[] getContextLocations() {
return new String[] { "struts.xml" };
}
@Test
public void testExecute() throws Exception {
ActionProxy proxy = getActionProxy("/unitTest");
UserAction test = (UserAction) proxy.getAction();
assertNotNull(test);
String result = proxy.execute();
assertEquals("success"?? result);
}
}
 4.Struts???á?
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<!– Development Mode –>
<constant name="struts.devMode" value="true" />
<package name="manager" namespace="/" extends="struts-default">//????default
<action name="unitTest" class="action.UserAction" method="list">
<result name="success">unitTest.jsp
</result>
</action>
</package>
</struts>
 ????5.????web???????
 
?????????Web.xml??????
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
????URL??http://localhost:8080/Struts2UnitDemo/unitTest.action