struts2_HelloWorld
第一个Struts2程序-Hello
1.创建web工程struts2-01-Hello
2.导入jar包到bin目录,jar地址:
https://files.cnblogs.com/files/aihuadung/struts%E6%89%80%E9%9C%80jar%E5%8C%85.zip
3.配置web.xml文件
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app id="WebApp_ID"> <display-name>struts2_01_Hello</display-name> <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> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
web.xml
4.src目录下创建struts.xml文件
5.在index.jsp文件中插入
<a href="hello.action" method="post">hello.action</a> <br>
6.创建执行HelloAction的结果文件hello.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>hello</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> hello World <br> </body> </html>
hello.jsp
7.创建HelloAction.java
package com.ahd.action; import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ActionSupport; public class HelloAction{ public String execute() throws Exception { // TODO Auto-generated method stub return “SUCCESS”; } }
HelloAction
8.编辑struts2.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="helloWorld" extends="struts-default" namespace="/"> <action name="hello" class="com.ahd.action.HelloAction"> <result name="success">/hello.jsp</result> </action> </package> </struts>
struts2.xml
9.运行结果
点击后
struts2_HelloWorld的更多相关文章
- 搭建一个简单的Struts2(Struts2_HelloWorld)
1.导入Jar包 2.配置web.xml 1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-ap ...
- [转]初探Struts2.0
本文转自:http://blog.csdn.net/kgd1120/article/details/1667301 Struts作为MVC 2的Web框架,自推出以来不断受到开发者的追捧,得到用广泛的 ...
- Struts2入门学习
1.Struts2的前身是Opensymphony的Webwork2,实际上Strut和Webwork2合并后形成Struts2. 2.一个HelloWord示例 1)创建Web应用,所需要的Ja ...
- Struts2 教程
一.Struts2是什么 Struts2是在WebWork2基础发展而来的.和Struts1一样, Struts2也是基于MVC的web层框架. 那么既然有了Struts1,为何还要Struts2? ...
- Struts2.x教程(一) Struts2介绍
一.Struts2是什么 Struts2是在WebWork2基础发展而来的.和Struts1一样, Struts2也是基于MVC的web层框架. 那么既然有了Struts1,为何还要Struts2? ...
- struts快速入门第一篇 —— struts相关XML配置映射及讲解
我们回忆一下在学习JavaWeb过程中(Jsp + servlet编程)所感受到的Servlet的不足: 1 Servllet很多时,web.xml中的代码会很多.这样一来,维护起来就不方便,不利于团 ...
- Java web struct入门基础知识
1.Struts2的前身是Opensymphony的Webwork2,实际上Strut和Webwork2合并后形成Struts2. 2.一个HelloWord示例 1)创建Web应用,所需要的Ja ...
- Struts和Spring MVC的比较(非原创)
文章大纲 一.Spring MVC项目例子二.Struts项目例子三.Struts和Spring MVC对比四.参考文章 一.Spring MVC项目例子 https://www.jianshu. ...
随机推荐
- WPF的AutoCompleteBox控件
AutoCompleteBox怎么用,网上都能查得到,本文就不再赘述. 最近在用的时候,发现一个小BUG,当匹配数据的个数超过了Drop页面能够显式的数据个数时,如果此时一直按键盘上“向下的箭头”,你 ...
- git 团队开发常用操作流程(适用于 gogs、gitlab、github)
git 团队开发常用操作流程(适用于 gogs.gitlab.github) NO1 项目构建者 (1)在远程仓库创建仓库 (2)将伙伴添加到仓库合作者中(无先后要求) (2)cd 到项目将要存放项目 ...
- Oracle ebs 数据脱敏
https://blog.csdn.net/pan_tian/article/details/16120351Data Masking可对数据进行不可逆的去身份化后,再用于非生产环境,同时自动保留引用 ...
- 英语演讲稿——Get Along with Fear
Hi. My name is Zhang Meng. I’m an engineer at Keysight. Today I’m not going to introduce my birthpla ...
- zookeeper集群配置详细教程
第一步:环境准备 环境 版本 说明 JDK 1.8 zookeeper运行所需 centos 7 操作系统 需要配置好JDK的环境变量 zookeeper-3.4.9.tar.gz 3.4.9 z ...
- JDK设计模式之——责任链(Filter)
责任链的设计模式可以参考Servlet的FilterChain.FilterChain中的每个Filter(过滤器)就像一个个的链条 web开发中 有时候需要对接口request和response进行 ...
- 深入分析Java I/O的工作机制 (二)
2.磁盘I/C工作机制 2.1几种访问文件的方式 内核空间和用户空间:内核空间是内核使用,用户空间是应用程序使用:除非编译内核要考虑内核空间,其余情况都可以按照用户空间处理.将用户空间和内核空间置于这 ...
- numpy中的norm用法
np.linalg.norm() computes the norm of a NumPy array according to an order, ord, which specifies the ...
- 项目中git版本控制及协作开发的常用操作(命令行,小乌龟,sourcetree)
一. git命令:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 小乌龟:htt ...
- Vue 中是如何解析 template 字符串为 VNode 的?
在接触 React 时候,我只了解到通过 babel 可以把 JSX 转成 VNode(通过调用 React.createElement 方法),但是对其具体是如何转换的却不了解. 很明显,回答失败. ...