下面写一个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. [django]django model的查询和更新

    再分享Django系列的另外几篇文章: Django model select的各种用法详解:https://mp.weixin.qq.com/s/JVh4UnS2Tql9gUVaBSoGuA Dja ...

  2. 根据构建类型动态设置AndroidManifest.xml文件中的meta-data

    当debug和release版本使用不同的值时,使用Gradle设置相应的值. Android主配置文件 <meta-data android:name="com.amap.api.v ...

  3. SpringBoot 项目健康检查与监控(转)

    前言 You build it,You run it, 当我们编写的项目上线后,为了能第一时间知晓该项目是否出现问题,常常对项目进行健康检查及一些指标进行监控.Spring Boot-Actuator ...

  4. mapper映射文件不发布

    mapper映射文件不发布的问题:在pom.xml中配置,指定加载哪些资源 <resources> <resource> <directory>src/main/j ...

  5. jenkins openshift 持续集成

    参数部分没有 不要照抄,只供参考 需求: CI利用confd+etcd生成配置文件 CI把git的COMMIT 传到openshift的buildconfigs #!/bin/bash echo ec ...

  6. 20165321 学习基础与C语言学习心得

    一.技能学习 我其实在小时候学过挺多东西,在我小学的时候,我曾经短时间地学过小提琴.拉丁舞.国画.书法,但是,由于各种原因,都没有继续学习下去.后来,在我小学四年级的时候,我接触到了二胡,于是,我开始 ...

  7. mybatis核心文件详解

    MyBatis配置文件详解 configuration  这是配置文件的根元素标签,所有的其他元素都要在这个标签下使用. environments   用于管理所有环境,并可以指定默认使用哪个环境,通 ...

  8. php实现记住密码下次自动登陆

    这篇博客里面还写到 实现“记住我的登录状态”的功能方法,简言之,就是对首先对session进行用户信息赋值,检测session,失效后,利用cookie对其赋值: 在实现过程中,根据网上一些代码贴,整 ...

  9. Introduction to debugging neural networks

    http://russellsstewart.com/notes/0.html The following advice is targeted at beginners to neural netw ...

  10. 准备spring

    下载对应版本:http://repo.spring.io/libs-release-local/org/springframework/spring/ Spring下载:https://spring. ...