Struts HelloWorld
First Step guide Jar package
Commons-fileupload-1.2.2.jar "File Upload related package"
Commons-io-2.0.1.jar "input and output related packages"
Struts2-core-2.3.4.1.jar "struts2 core Feature Pack"
Xwork-core-2.3.4.1.jar "Xwork Core Pack"
Ognl-3.0.5.jar "OGNL expression feature Support table"
Commons-lang3-3.1.jar "struts extension to Java.lang package"
Freemarker-2.3.19.jar "Struts tag Template Library jar file"
Javassist-3.11.0.ga.jar "struts-to-bytecode processing related jar"
Step two configure Web. xml
<!--Introducing the Struts core filter-<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>/*</url-pattern> < /filter-mapping>
The third step is to develop an action processing request
Package com.struts.action; Import Com.opensymphony.xwork2.ActionSupport; Public class extends actionsupport { // processing request public throws Exception { System.out.println ("Access to Action, processing request"); System.out.println ("Call service"); return "Success"; }}
Fourth Step configuration Struts.xml file is placed under SRC
<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE struts Public "-//apache software foundation//dtd struts Configuration 2.0//en" "Http://stru Ts.apache.org/dtds/struts-2.0.dtd "><Struts> < Packagename= "xxxx"extends= "Struts-default"> <Actionname= "Hello"class= "Com.struts.action.helloaction"Method= "Execute"> <resultname= "Success">/myjsp.jsp</result> </Action> </ Package> </Struts>
Well, struts HelloWorld is finished.
Struts2 framework of Hello World