标签:com http blog class div img c code java log t
1、web.xml
1 <filter> 2 <filter-name>struts2</filter-name> 3 <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 4 </filter> 5 <filter-mapping> 6 <filter-name>struts2</filter-name> 7 <url-pattern>/*</url-pattern> 8 </filter-mapping>
2、struts.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE struts PUBLIC 3 "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 4 "http://struts.apache.org/dtds/struts-2.0.dtd"> 5 <struts> 6 <package name="default" namespace="/" extends="struts-default"> 7 <action name="hello" class="com.action.TestAction"> 8 <result>/success.jsp</result> 9 </action> 10 </package> 11 </struts>
3、struts.properties
1 <struts.i18n.encoding value="UTF-8"/>
4、index.jsp
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <%@ taglib prefix="s" uri="/struts-tags"%> 4 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 5 <html> 6 <head> 7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 8 <title>Insert title here</title> 9 </head> 10 <body> 11 <s:a action="hello">hello</s:a> 12 </body> 13 </html>
5、success.jsp
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <%@ taglib prefix="s" uri="/struts-tags"%> 4 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 5 <html> 6 <head> 7 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 8 <title>Insert title here</title> 9 </head> 10 <body> 11 <s:property value="helo"/> 12 </body> 13 </html>
6、TestAction.java
1 package com.action; 2 3 import com.opensymphony.xwork2.ActionSupport; 4 5 public class TestAction extends ActionSupport { 6 private static final long serialVersionUID = 1L; 7 private String helo; 8 9 public String getHelo() { 10 return helo; 11 } 12 13 public void setHelo(String helo) { 14 this.helo = helo; 15 } 16 17 public String execute() throws Exception { 18 helo = "Hello World!"; 19 return SUCCESS; 20 } 21 }
7、Tree
8、Lib
标签:com http blog class div img c code java log t
原文地址:http://www.cnblogs.com/nnxiaod/p/3701715.html