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. ...
随机推荐
- hive 日常技巧
--删除表中重复数据 delete from vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by ...
- 软件测试-chapter2-homework2
程序一 1.the fault:for循环中i>0应改为i>=0 for (int i=x.length-1; i >= 0; i--) 2. (Reachability可达性,是f ...
- JS全局变量与局部变量
一句话概括:在函数外声明的变量都为全局变量,在函数内声明的为局部变量. 一.局部变量和全局变量重名会覆盖全局变量 var a = 1; function test1() { var a = 2; al ...
- uintAPi 之Renderer.material
Renderer.material public Material material; Returns the first instantiated Material assigned to the ...
- Chapter 8 The Simplest Plug-in Solution
This chapter introduces the simplest plug-in solution that are applicable to the four major componen ...
- 【ZCTF】easy reverse 详解
0x01 前言 团队逆向牛的解题思路,分享出来~ 0x02 内容 0. 样本 bbcdd1f7-9983-4bf4-9fde-7f77a6b947b4.dll 1. 静态分析 使用IDAP ...
- Javascript高级编程学习笔记(40)—— DOM(6)CDATASection、DocumentType
CDATASection类型 CDATASection类型是只针对XML文档的类型 因为浏览器无法解析 在浏览器中创建CDATASection的函数也无法正常使用 该类型有以下属性 nodeType: ...
- python写的翻译代码
# -*- coding: utf-8 -*- from Tkinter import *import difflibimport urllib2import urllib # python2.7才需 ...
- Key-Value 数据库简介
1.Aerospike 官方网站:https://www.aerospike.com/ Aerospike是一个以分布式为核心基础,可基于行随机存取内存中索引.数据或SSD存储中数据的数据库. Aer ...
- 实现文件上传 你get了吗???
实现文件上传: 1.jar包 需要用到两个jar包: commons-io.jar commons-fileupload.jar 下载地址:https://mvnrepository.com/ 2.f ...