struts2 的入门案例
下面写一个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 的入门案例的更多相关文章
- (转)Struts2快速入门
http://blog.csdn.net/yerenyuan_pku/article/details/66187307 Struts2框架的概述 Struts2是一种基于MVC模式的轻量级Web框架, ...
- Struts2第一个入门案例
一.如何获取Struts2,以及Struts2资源包的目录结构的了解 Struts的官方地址为http://struts.apache.org 在他的主页当中,我们可以通过左侧的Apache ...
- SpringMVC入门案例及请求流程图(关于处理器或视图解析器或处理器映射器等的初步配置)
SpringMVC简介:SpringMVC也叫Spring Web mvc,属于表现层的框架.Spring MVC是Spring框架的一部分,是在Spring3.0后发布的 Spring结构图 Spr ...
- SpringMvc核心流程以及入门案例的搭建
1.什么是SpringMvc Spring MVC属于SpringFrameWork的后续产品,已经融合在Spring Web Flow里面.Spring 框架提供了构建 Web 应用程序的全功能 M ...
- Struts 2入门案例及登录
一:入门案例 步骤如下: 1.导入jar包 2.配置web.xml文件 3.在src下创建名称为struts.xml的配置文件 4.创建编写HelloWorldAction 5.创建index.jsp ...
- Spring入门案例 idea创建Spring项目
spring入门案例 idea创建spring项目 Spring介绍 Spring概述 Spring是一个开源框架,Spring是2003年兴起的轻量级java开发框架,由Rod Johnson 在其 ...
- JavaWeb框架_Struts2_(一)----->Struts2 框架入门
1. 框架入门 2.1 Struts2简介 (1). Struts2是一种基于MVC模式的的轻量级Web开发框架. MVC模式:MVC全名是Model View Controller,是模型(mo ...
- MyBatis入门案例、增删改查
一.MyBatis入门案例: ①:引入jar包 ②:创建实体类 Dept,并进行封装 ③ 在Src下创建大配置mybatis-config.xml <?xml version="1.0 ...
- Hibernate入门案例及增删改查
一.Hibernate入门案例剖析: ①创建实体类Student 并重写toString方法 public class Student { private Integer sid; private I ...
随机推荐
- 死锁与递归锁 信号量 event 线程queue
1.死锁现象与递归锁 死锁:是指两个或两个以上的进程或线程在执行过程中,因争抢资源而造成的一种互相等待的现象,若无外力作用,它们都将无法推进下去,此时称系统处于死锁状态或系统产生了死锁,这些永远在互相 ...
- logging日志模块的使用
logging日志模块的使用 logging模块中有5个日志级别: debug 10 info 20 warning 30 error 40 critical 50 通常使用日志模块,是用字典进行配置 ...
- C 逗號表達式 與返回值
逗號表達式的返回值是最後一個表達式的值 int z; z=(,); printf("%d\n",z);//6 int a; printf(*,a*,a+));//20 a=3*5, ...
- sjw-风评评测-定位页面元素
一.手工标准化操作流程: 1.登录系统 2.登录后的页面点击:账户设置 3.点击“重新评测”,进入到风险评测页面 4.答完8道题 5.勾选条件checkbox 6.点击“提交” 提交后的页面 二.自动 ...
- 笔记:Python 字符串小记
1. 字符串是以''或""括起来的任意文本,如果'本身也是一个字符,那就可以用""括起来,比如"I'm OK" >>> p ...
- SVM、LR、决策树的对比
一.LR LR,DT,SVM都有自身的特性,首先来看一下LR,工业界最受青睐的机器学习算法,训练.预测的高效性能以及算法容易实现使其能轻松适应工业界的需求.LR还有个非常方便实用的额外功能就是它并不会 ...
- ida pro 使用
交互式反汇编器专业版(Interactive Disassembler Professional),人们常称其为IDA Pro,或简称为IDA.是目前最棒的一个静态反编译软件,为众多0day世界的成员 ...
- php二维数组搜索
$ar = array( 2 => array( 'catid' => 2, 'catdir' => 'notice', ), ...
- 使用socat查看ios日志
仅供记录自己查看 mac连接ios后进程ios shell apt-get socat安装 socat socat - UNIX-CONNECT:/var/run/lockdown/syslog.so ...
- python对字典及列表递归排序
对字典内所有内容进行排升序排序,包括,子数组,子字典 需要注意: 1.字典因为是在一定程序上无序的,所以这里采用了内置包,来变成有序字典 from collections import Ordered ...