1、Struts2 简介

Struts 2是Struts的下一代产品,是在 struts 1和WebWork的技术基础上进行了合并的全新的Struts 2框架。其全新的Struts 2的体系结构与Struts 1的体系结构差别巨大。Struts 2以WebWork为核心,采用拦截器的机制来处理用户的请求,这样的设计也使得业务逻辑控制器能够与ServletAPI完全脱离开,所以Struts 2可以理解为WebWork的更新产品。虽然从Struts 1到Struts 2有着太大的变化,但是相对于WebWork,Struts 2的变化很小。

2、Struts2实例之HelloWorld

2.1 web.xml配置代码

 <filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

2.2 struts.xml配置代码

 <struts>
<package name="helloWorld" extends="struts-default">
<action name="hello" class="com.action.HelloWorldAction">
<result name="success">helloWorld.jsp</result>
</action>
</package>
</struts>

2.3 HelloWorldAction代码

 public class HelloWorldAction implements Action{

     @Override
public String execute() throws Exception {
System.out.println("执行了Action默认方法!!");
return SUCCESS;
}
}

2.4 helloWorld.jsp代码

 <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Struts2</title>
</head>
<body>
Struts2大爷你好!
</body>
</html>

  每天进步一点点,勿忘初心,一切都是最好的安排。

第一个Struts2程序之HelloWorld的更多相关文章

  1. 【Java】手动编写第一个Java程序,HelloWorld!

    第一个Java程序HelloWorld! 环境前提:确保你已经配置好了JDK8的环境变量,和本体安装 打开文本编辑器,这里我使用的是EditPlus 编写代码: public class Hello{ ...

  2. 2.第一个Struts2程序-HelloWorld程序

    1.新建Web Project项目:Study_Struts2 2.新建HelloWordAction.java类 3.复制struts.xml文件到src目录下,配置struts.xml文件内容如下 ...

  3. struts2基础---->第一个Struts2程序

    学习struts2的第一个程序,这里只会涉及到简单的代码编写.有一个夜晚我烧毁了所有的记忆,从此我的梦就透明了:有一个早晨我扔掉了所有的昨天,从此我的脚步就轻盈了. Struts的项目

  4. 第一个duilib程序 - 实现HelloWorld详解

    duilib是一个windows下的皮肤库,用win32写的... 先看个效果图吧: 要使用duilib库,必须先把库导入,代码如下: View Row Code 1 #include "x ...

  5. 1、第一个Struts2程序

    为了让我们以后开发方便,我们需要配置struts.xml的dtd的头,这样在编写struts.xml文件中可以有提示! 操作如下: (1)打开myeclipse→window→Preferences→ ...

  6. 一个struts2程序

    1.index.jsp 2.struts.xml 3.Loginaction.java package action; import java.io.File; import java.io.File ...

  7. Struts2入门(1)-第一个Struts2程序

    目录结构 C:\WorkSpace\java\StrutsTest\src\main C:\WorkSpace\java\StrutsTest\src\test C:\WorkSpace\java\S ...

  8. 第一个PHP程序-HelloWorld

    <?php //echo输出字符串 echo "Hello php!你好 php" ; 以上程序输出结果为:Hello php!你好 php

  9. 第一个Struts2程序

    Struts2.3.16, Tomcat6.0.37,Java8 /web.xml <?xml version="1.0" encoding="UTF-8" ...

随机推荐

  1. Win7 64位ORACLE取数字乱码的解决

    参见网址http://www.2cto.com/database/201304/201767.html 首先是PLSQL DEVELOPER 直接报错 NLS_LANG 错误 第一步是在命令行下测试 ...

  2. father of the archangel of death"?

    e wields an axe, a sword and a machine gun and his battlefield pranks have become as legendary as hi ...

  3. mkstemp生成临时文件

    使用该函数可以指定目录生成临时文件,函数原型为 int mkstemp(char *template); 应用举例 int main(int argc, char *argv[]) { /* char ...

  4. UIImage学习

    UIImage A UIImage object is a high-level way to display image data. You can create images from files ...

  5. 【zz】matlab 均值方差

    转自:http://blog.sina.com.cn/s/blog_4936c31d01011v8j.html 1. 均值 Matlab函数:mean >>X=[1,2,3] >&g ...

  6. 北大poj-1011

    木棒 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 136132   Accepted: 32036 Description ...

  7. 【C编译器】MinGw安装与使用(调试问题待续)

    不想装vs2005之类的,想要一个轻量级的C语言编译器,希望将焦点放在如何写好代码上: 本人信奉:代码质量是靠设计和检视保证的,不是靠调试: 1.安装MinGW http://www.mingw.or ...

  8. Linux中的find(-atime、-ctime、-mtime)指令分析

    本篇主要对find -atime(-ctime..mtime)指令的用法.参数.运行情况进行分析 用法: find . {-atime/-ctime/-mtime/-amin/-cmin/-mmin} ...

  9. C#获取北京时间与设置系统时间

    获取北京时间 public static DateTime GetBeijingTime() { DateTime dt; // 返回国际标准时间 // 只使用 timeServers 的 IP 地址 ...

  10. system_call中断处理过程分析

    本文所有的分析内容都是基于Linux3.18.6内核,鉴于对应不同内核版本,系统调用的实现不相同.若需要分析其他版本内核的系统调用的实现过程,请谨慎参考. system_call函数的功能是用来响应外 ...