Struts相关
使用Struts2流程:
1.导入Struts2类包
2.在Web源代码文件夹中,创建名为struts.xml的配置文件。在其中定义Action对象,其关键代码如下:
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="Mypackage" namespace="/" extends="struts-default">
<!-- 定义Action -->
<action name="first">
<!-- 定义处理成功后的映射界面 -->
<result>/first.html</result>
</action>
</package>
</struts>
3.在web.xml文件中声明Struts2提供的过滤器,类名为"org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter"
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>Struts2First</display-name>
<filter> <!-- 配置Struct2过滤器 -->
<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>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
4.初始界面index.jsp:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="first.action">跳转</a> <!-- 点击链接后,请求交给名为first的Action处理 -->
</body>
</html>
5.处理后的映射界面first.jsp:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
我的第一个struts2实例
</body>
</html>
Struts相关的更多相关文章
- (原)Struts 相关资源下载
官网:http://struts.apache.org 点击[Download],进入页面如下,可以看到下载的资源: 点击[struts-2.3.20-all.zip],就能获取Struts2项目所有 ...
- struts快速入门第一篇 —— struts相关XML配置映射及讲解
我们回忆一下在学习JavaWeb过程中(Jsp + servlet编程)所感受到的Servlet的不足: 1 Servllet很多时,web.xml中的代码会很多.这样一来,维护起来就不方便,不利于团 ...
- Struts框架——(二)Struts原理with登录实例
二. Struts基本工作流程 假设现在有以下情景: 用户正在浏览一个用STRUTS的技术构建的网站主页,主页上有个登陆表单,用户填好登陆名和密码,单击"登陆"按钮,就激活了以下一 ...
- struts理解
最近大家都在找工作,我好迷茫,觉得自己会的东西太少了.所以决定开始学习SSH三大框架. 首先是struts. struts是基于mvc模式的框架.(struts其实也是servlet封装,提高开发效率 ...
- Struts
Struts是基于MVC的框架,它进一步的对MVC进行了封装. MVC 概念 MVC全名是Model View Controller,是模型(model)—视图(view)—控制器(controlle ...
- [转]Struts1.x系列教程(1):用MyEclipse开发第一个Struts程序
转载地址:http://www.blogjava.net/nokiaguy/archive/2009/01/13/251101.html 本系列教程将详细介绍Struts 1.x的基本原理和使用方法, ...
- 第一个struts案例及分析
软件中的框架,是一种半成品: 我们项目开发需要在框架的基础上进行!因为框架已经实现了一些功能,这样就可以提高开发效率! Struts2 = struts1 + xwork (struts是基于MV ...
- 使用struts+spring+hibernate组装web应用
这篇文章将讨论怎样组合几个着名的框架去做到松耦合的目的,怎样建立你的构架,怎样让你的各个应用层保持一致.富于挑战的是:组合这些框架使得每一层都以一种松耦合的方式彼此沟通,而与底层的技术无关.这篇文章将 ...
- Struts1——从BeanUtils看struts的实现原理2
上一篇博客中我们简单的介绍了BeanUtils的使用.以及其最主要的原理,今天我们进一步的理解这个类在Struts1中的使用. 首先我们先回想一下搭建一个简单的基于Struts1框架的 ...
随机推荐
- win7系统下python安装numpy,matplotlib,scipy和scikit-learn
1.安装numpy,matplotlib,scipy和scikit-learn win7系统下直接采用pip或者下载源文件进行安装numpy,matplotlib,scipy时会遇到各种问题,这是因为 ...
- Fiddler学习笔记
1. [HTTP]Fiddler(一) - Fiddler简介 Fiddler使用代理(127.0.0.1:8888), 打开Fiddler会自动设置该代理. 2.[HTTP]Fiddler(二) - ...
- CentOS系统中基于Apache+php+mysql的许愿墙网站的搭建
1.首先,我们需要两台虚拟机(CentOS7,Linux文本). 2.给两台虚拟机配置网络环境分别为桥接模式 CentOS7 ip为192.168.100.139.24,linux文本ip为192.1 ...
- ->code vs 2879 堆的判断(堆的学习一)
2879 堆的判断 时间限制: 1 s 空间限制: 32000 KB 题目等级 : 黄金 Gold 题目描述 Description 堆是一种常用的数据结构.二叉堆是一个特殊的二叉树,他的父 ...
- Android安全攻防战,反编译与混淆技术完全解析(上)
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/49738023 之前一直有犹豫过要不要写这篇文章,毕竟去反编译人家的程序并不是什么值 ...
- 在win7环境下批量修改文件权限
在附件->命令提示符->右键->以管理员身份运行 进入你需要修改的文件位置,然后输入下面两条命令 takeown /f * /A /R icacls * /t /grant:r ev ...
- October 31st Week 45th Monday 2016
While there is life there is hope. 一息若存,希望不灭. Go on living even if there is no hope. Knowing is not ...
- centos 使用 locate
centos 第一次使用locate时报错: locate: can not stat () `/var/lib/mlocate/mlocate.db': 没有那个文件或目录 因为locate相关的索 ...
- 其原因可能是堆被损坏,这说明 100BloodCellSegTest.exe 中或它所加载的任何 DLL 中有 Bug。
这个问题可能是内存空间释放了两次,比如使用cvLoadImage函数时IplImage* img = cvLoadImage(buf.c_str(),1);,注意要释放内存,但不要释放了两次cvRel ...
- python学习笔记(5)--迭代器,生成器,装饰器,常用模块,序列化
生成器 在Python中,一边循环一边计算的机制,称为生成器:generator. 如: >>> g = (x * x for xin range(10)) >>> ...