struts quick start
1.create a dynamic web project
2.import the needed jar(about 11)

3. request page(index.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="${pageContext.request.contextPath }/hello.action">点我进入sturts2</a>
</body>
</html>
4.result page(helloStruts2.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>
<h1> hello struts2</h1>
</body>
</html>
5.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>startStruts</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>
</web-app>
6.struts.xml(classpath:src)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" /> <package name="default" extends="struts-default">
<default-action-ref name="default"></default-action-ref>
<action name="default" class="com.goodfan.action.HelloAction" method="execute">
<result name="success">/WEB-INF/jsp/index.jsp</result>
</action>
<action name="hello" class="com.goodfan.action.HelloAction" method="execute">
<result name="success">/WEB-INF/jsp/helloStruts2.jsp</result>
</action>
</package>
</struts>
7. class action
HomeAction
package com.goodfan.action;
public class HomeAction {
public String execute(){
return "success";
}
}
HelloAction
package com.goodfan.action;
public class HelloAction {
public String execute(){
return "success";
}
}
struts quick start的更多相关文章
- Struts Hello World Example
In this tutorial we show you how to develop a hello world web application using classic Struts 1.3 f ...
- 菜鸟学Struts2——Struts工作原理
在完成Struts2的HelloWorld后,对Struts2的工作原理进行学习.Struts2框架可以按照模块来划分为Servlet Filters,Struts核心模块,拦截器和用户实现部分,其中 ...
- [算法]——快速排序(Quick Sort)
顾名思义,快速排序(quick sort)速度十分快,时间复杂度为O(nlogn).虽然从此角度讲,也有很多排序算法如归并排序.堆排序甚至希尔排序等,都能达到如此快速,但是快速排序使用更加广泛,以至于 ...
- Struts的拦截器
Struts的拦截器 1.什么是拦截器 Struts的拦截器和Servlet过滤器类似,在执行Action的execute方法之前,Struts会首先执行Struts.xml中引用的拦截器,在执行完所 ...
- Struts框架的核心业务
Struts的核心业务 Struts核心业务有很多,这里主要介绍了比较简单一些的: 请求数据的处理,和数据自动封装,类型自动转换 1.Struts中数据处理 1.1.方式1:直接过去servletap ...
- Struts的文件上传下载
Struts的文件上传下载 1.文件上传 Struts2的文件上传也是使用fileUpload的组件,这个组默认是集合在框架里面的.且是使用拦截器:<interceptor name=" ...
- 配置hibernate,Struts。文件
hibernate文件配置 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernat ...
- hibernate与Struts框架结合编写简单针对修改练习
失败页面fail.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" ...
- 3. 解析 struts.xml 文件
1. struts.xml 文件基本配置: 主要放在资源路径下,配置 sturts2相关的 Action , 拦截器等配置 <struts> <!-- 设置常量 --> < ...
随机推荐
- Ubuntu16.04LTS安装集成开发工具IDE: CodeBlocks 和Eclipse-cdt
上文中,我们已经介绍了QT5.10.0在Ubuntu下的安装 https://www.cnblogs.com/si-lei/p/9240230.html, 接下来我们介绍CodeBlocks以及Ecl ...
- 【洛谷2416】泡芙(Tarjan+LCA)
题目描述 火星猫经过一番努力终于到达了冥王星.他发现冥王星有 \(N\) 座城市,\(M\) 条无向边.火星猫准备出发去找冥王兔,他听说有若干泡芙掉落在一些边上,他准备采集一些去送给冥王兔.但是火星猫 ...
- 查看db连接数sql
/****** Object: StoredProcedure [dbo].[SP_Conn] Script Date: 12/09/2018 19:03:28 ******/ SET ANSI_NU ...
- [USACO07DEC]泥水坑Mud Puddles BFS BZOJ 1627
题目描述 Farmer John is leaving his house promptly at 6 AM for his daily milking of Bessie. However, the ...
- 23.3Sum(三数和为零)
Level: Medium 题目描述: Given an array nums of n integers, are there elements a, b, c in nums such tha ...
- python用字典实现switch..case类似的函数调用
python中没有swich..case,若要实现一样的功能,又不想用if..elif来实现,可以充分利用字典进行实现 主要是想要通过不同的key调用不同的方法,在学习过程中,发现不管输入的key是什 ...
- 网络瓶颈、线程死锁、内存泄露溢出、栈堆、ajax
网络瓶颈:网络传输性能及稳定性的一些相关元素 线程死锁:多个线程因竞争资源造成的一种僵局 下面我们通过一些实例来说明死锁现象. 先看生活中的一个实例,2个人一起吃饭但是只有一双筷子,2人轮流吃(同时拥 ...
- Tensorlflow-解决非线性回归问题
import tensorflow as tfimport numpy as npimport matplotlib.pyplot as plt #使用numpy生成200个随机点,范围从-0.5到0 ...
- 解决linux一段时间不操作失去连接的问题
解决mac下ssh空闲一段时间自动断开的问题 http://www.haorooms.com/post/mac_iterm2_ssh 问题现象 用 ssh 命令连接服务器之后,如果一段时间不操作,再次 ...
- SSH 项目建立过程
1. 加入 Spring 1). 加入 jar 包 2). 配置 web.xml 文件 <context-param> <param-name>contextConfigLoc ...