下面写一个struts2 的一个小例子

首先需要struts2 的jar    可以在Struts 官网上下载    本人使用的版本是2.5 17

官网地址: http://struts.apache.org/

      hello.jsp  

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="HelloAction.action">hello 请求发起</a>
</body>
</html>

  hello1.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
响应成功!!!!!!!!!
</body>
</html>

  web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>StrutsTwo</display-name>
<!-- 过滤器拦截 /* -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <welcome-file-list>
<welcome-file>hello.jsp</welcome-file>
</welcome-file-list>
</web-app>

  helloAction

package com.mycom;

import com.opensymphony.xwork2.Action;

public class HelloAction implements Action{

	public String execute() throws Exception {

		System.out.println("执行后台代码 !!!!!!!!!!!   走了helloAction");
return SUCCESS;
} }

  struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="default" namespace="/" extends="struts-default">
<action name="HelloAction" class="com.mycom.HelloAction">
<result name="success">hello1.jsp</result>
</action>
</package> </struts>

  运行即可

响应结果:

struts2 的入门案例的更多相关文章

  1. (转)Struts2快速入门

    http://blog.csdn.net/yerenyuan_pku/article/details/66187307 Struts2框架的概述 Struts2是一种基于MVC模式的轻量级Web框架, ...

  2. Struts2第一个入门案例

      一.如何获取Struts2,以及Struts2资源包的目录结构的了解    Struts的官方地址为http://struts.apache.org 在他的主页当中,我们可以通过左侧的Apache ...

  3. SpringMVC入门案例及请求流程图(关于处理器或视图解析器或处理器映射器等的初步配置)

    SpringMVC简介:SpringMVC也叫Spring Web mvc,属于表现层的框架.Spring MVC是Spring框架的一部分,是在Spring3.0后发布的 Spring结构图 Spr ...

  4. SpringMvc核心流程以及入门案例的搭建

    1.什么是SpringMvc Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面.Spring 框架提供了构建 Web 应用程序的全功能 M ...

  5. Struts 2入门案例及登录

    一:入门案例 步骤如下: 1.导入jar包 2.配置web.xml文件 3.在src下创建名称为struts.xml的配置文件 4.创建编写HelloWorldAction 5.创建index.jsp ...

  6. Spring入门案例 idea创建Spring项目

    spring入门案例 idea创建spring项目 Spring介绍 Spring概述 Spring是一个开源框架,Spring是2003年兴起的轻量级java开发框架,由Rod Johnson 在其 ...

  7. JavaWeb框架_Struts2_(一)----->Struts2 框架入门

    1.  框架入门 2.1  Struts2简介 (1). Struts2是一种基于MVC模式的的轻量级Web开发框架. MVC模式:MVC全名是Model View Controller,是模型(mo ...

  8. MyBatis入门案例、增删改查

    一.MyBatis入门案例: ①:引入jar包 ②:创建实体类 Dept,并进行封装 ③ 在Src下创建大配置mybatis-config.xml <?xml version="1.0 ...

  9. Hibernate入门案例及增删改查

    一.Hibernate入门案例剖析: ①创建实体类Student 并重写toString方法 public class Student { private Integer sid; private I ...

随机推荐

  1. 共分为六部完成根据模板导出excel操作

    第一步.设置excel模板路径(setSrcPath) 第二步.设置要生成excel文件路径(setDesPath) 第三步.设置模板中哪个Sheet列(setSheetName) 第四步.获取所读取 ...

  2. sap 创建odata服务,通过http向数据库 进行增删改查

    https://blog.csdn.net/stone0823/article/details/71057172 1:通过 事物码 se11 创建 数据库表  zemp.表 zemp中 含有empid ...

  3. 基于jquery ajax的多文件上传进度条

    效果图 前端代码,基于jquery <!DOCTYPE html> <html> <head> <title>主页</title> < ...

  4. Hybrid设计--Hybrid中Native能力的设计

    稍微成熟的团队,header一定是不利于业务的UI组件,这个组件会封装在view层,方便前端使用.对业务前端开发来说,不用关注header是如何实现的,只用框架层释放的API.(一个前端有一个自己的U ...

  5. python one

    哈哈,今天把它搞了 谁? Python啊! ..... *************************************** python:解释性语言,功能很强大,现在很有市场! & ...

  6. 前端 json 导出 excel

    参考:https://blog.csdn.net/abel_yang/article/details/78684786 在github上有大神提供现成的插件,非常感谢 https://cuikangj ...

  7. node.js初识10

    post请求 form.html <!DOCTYPE html> <html lang="en"> <head> <meta charse ...

  8. [提权] 脏牛漏洞 Dirty COW CVE-2016-5195 2.6.22 < 3.9 (x86/x64)

    /* * (un)comment correct payload first (x86 or x64)! * * $ gcc cowroot.c -o cowroot -pthread * $ ./c ...

  9. C++ new运算符

    new 分配的数据类型:内置数据类型.自定义数据类型. 如果不成功,则 new 将返回零或引发异常:编写自定义异常处理例程并调用 _set_new_handler运行库函数(以您的函数名称作为其参数) ...

  10. c# Tuple新特性

    class Operation     {         internal Tuple<int, int> FindMinMax(List<int> list)       ...