1、环境搭建
1、在pom.xml導入相應的jar包:struts2-core
2、設置web.xml添加struts2的過濾器:
1 <filter> 2 <filter-name>struts2</filter-name> 3 <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 4 </filter> 5 6 <filter-mapping> 7 <filter-name>struts2</filter-name> 8 <url-pattern>/*</url-pattern> 9 </filter-mapping>3、創建相應的action類(寫一個execute方法,并返回一個字符串)
1 public void HelloAction{ 2 public String execute(){ 3 System.out.println("Hello Action"); 4 return "success"; 5 } 6 }4、編寫struts2.xml文件
<struts><package name="default" namespace="/" extends="struts-default"><action name="hello" class="action.HelloAction"><result name="success">/index.jsp</result></action> </struts>?
轉載于:https://www.cnblogs.com/Akke/p/4980740.html
總結
- 上一篇: Mysql 索引的基础(下)
- 下一篇: ELK日志管理之——logstash部署