码迷,mamicode.com
首页 > 其他好文 > 详细

Struts2 Demo

时间:2014-05-01 07:30:35      阅读:274      评论:0      收藏:0      [点我收藏+]

标签:com   http   blog   class   div   img   c   code   java   log   t   

1、web.xml

mamicode.com,码迷
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>
mamicode.com,码迷

2、struts.xml

mamicode.com,码迷
 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>
mamicode.com,码迷

3、struts.properties

1 <struts.i18n.encoding value="UTF-8"/> 

4、index.jsp

mamicode.com,码迷
 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>
mamicode.com,码迷

5、success.jsp

mamicode.com,码迷
 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>
mamicode.com,码迷

6、TestAction.java

mamicode.com,码迷
 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 }
mamicode.com,码迷

7、Tree

mamicode.com,码迷

8、Lib

mamicode.com,码迷

 

Struts2 Demo,码迷,mamicode.com

Struts2 Demo

标签:com   http   blog   class   div   img   c   code   java   log   t   

原文地址:http://www.cnblogs.com/nnxiaod/p/3701715.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!