一、struts2简介

    struts2是一个用来开发MVC应用程序的框架。它提供了Web应用程序开发过程中的一些常见问题的解决方案。

  1.struts2的作用域范围:三层架构当中的第一层,相当于MVC层,其出现的作用就是标准化MVC,让程序员在某个标准阿下进行程序的开发。

  2.struts2的下载:http://struts.apache.org/download.cgi#struts2324

          jar包、源码、文档一应俱全。

  3.发展历史:Struts1是世界上第一个MVC的框架,在2001年发布;Struts2不是Struts1的升级,是由WebWork发展起来的,吸收了Struts1和WebWork的优点。

  4.Struts2能够解决的问题:

    (1)页面导航活动的开始

    (2)用户输入数据的合法性验证

    (3)统一的布局

    (4)可扩展性

    (5)国际化和本地化

    (6)支持Ajax 

    (7)解决表单的重复提交问题

    ......

  5.struts2的工作原理:写到这里突然想到了王建老师,之前王健老师教我们的东西突然发现和struts2极其相似,真的非常感谢王健老师。不赘述。见之前的BaseServlet原理。

  6.struts2的第一个小项目:Hello,World!

    (1)应当加入的基础包包括:asm-3.3.jar、asm-commons-3.3.jar、asm-tree-3.3.jar、commons-fileupload-1.3.1.jar、commons-io-2.2.jar、commons-lang-2.4.jar、commons-lang3-3.2.jar、commons-logging-1.1.3.jar、freemarker-2.3.22.jar、javassist-3.11.0.GA.jar、ognl-3.0.6.jar、struts2-core-2.3.24.jar、xwork-core-2.3.24.jar    一共13个包。

    (2)修改index.jsp页面:

 1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
 2 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 3 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 4 <html>
 5   <head>
 6     <meta http-equiv="content-type" content="text/html;charset=utf-8">
 7     <title>Insert title here !</title>
 8   </head>
 9   
10   <body>
11       <a href="<c:url value='/myaction/helloWorldAction.action'/>">hello,world</a>  
12   </body>
13 </html>
index.jsp

相关文章: