标签:style blog http color java os io 2014
struts-2.3.16.3, tomcat 8.0.3.0, netbeans 8.0
第一步
拷贝 jar 包 (下载的 struts 包里面有例子)
第二步
配置 web.xml
1 <!-- struts2 借用filter实现过滤--> 2 <filter> 3 <filter-name>struts2</filter-name> 4 <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 5 </filter> 6 7 <filter-mapping> 8 <filter-name>struts2</filter-name> 9 <url-pattern>/*</url-pattern> 10 </filter-mapping> 11 <!--end of struts-->
第三步
配置 struts.xml
1 <struts> 2 <package name="first" extends="struts-default"> 3 <action name="helloworld" class="llh.example.action.HelloWorldAction" method="execute"> 4 <result name="success">/a.jsp</result> 5 </action> 6 </package> 7 </struts>
package llh.example.action; /** * @author Administrator * */ public class HelloWorldAction { private String message; public String getMessage() { return message; } public String execute() { message = "第一个 struts2 应用"; return "success"; } }
1 <body> 2 <a href="helloworld">HelloWord</a> 3 </body>
1 <body> 2 ${message} 3 </body>
标签:style blog http color java os io 2014
原文地址:http://www.cnblogs.com/hualongbei/p/3897288.html