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> <!-- 设置常量 --> < ...
随机推荐
- Qt 学习之路 2(51):布尔表达式树模型
Qt 学习之路 2(51):布尔表达式树模型 豆子 2013年5月15日 Qt 学习之路 2 17条评论 本章将会是自定义模型的最后一部分.原本打算结束这部分内容,不过实在不忍心放弃这个示例.来自于 ...
- 本地localhost:端口号(自己设置的Apache的端口号)打不开问题解决了!开心、哭泣
想不来自己有多蠢!历经4个月再没学,刚开始xampp的端口问题解决不了,系统竟然会自动改回去端口数据(哭晕) 后来一直显示Apache端口80占用,各种百度之后发现单纯浏览器都访问不了localhos ...
- Liunx 挂载磁盘
查看已经挂载的分区和文件系统类型 [root@VM_101_18212122_centos /]# df -T Filesystem Type 1K-blocks Used Available Use ...
- 打开页面时就提交,可以做一些自动登陆 还有SICLOGIN的测试代码
<HTML> <head> <title> Untitled Document</title > (1)自动提交表单: <meta http- ...
- bzoj2190 仪仗队
题目传送门 思路: 哪些点能被人看到,其实就是哪些点不会被其他点挡住,只要顶点的坐标互质就可以了,互质用欧拉函数算.特殊考虑一下n=1和0的情况. 欧拉函数,Φ(x)=x(1-1/p1)(1-1/p2 ...
- CodeChef - RIN 最小割应用 规划问题
题意:给定\(n\)门课和\(m\)个学期,每门课在每个学期有不同的得分,需要选定一个学期去完成,但存在约束条件,共有\(k\)对课程需要\(a\)在\(b\)开始学前学会,求最大得分(原问题是求最高 ...
- QQ互联 网站应用接入
1.准备工作 接入qq登陆前,网站需要先进行申请,获得对应的appid和appkey, 以保证后续流程中可正确对网站与用户进行授权. 2.放置qq登陆按钮. 在网站页面上放置“qq登录”按钮,并为按钮 ...
- linux 工具(1)------终端提示符配置
Linux环境变量,PS1用于设置终端的提示符. 设置规则 设置方法 设置规则 \d :代表日期,格式为 Weekday Month Date,例如 "Mon Aug 1" \H ...
- Linux总线设备驱动模型
1. Linux2.6内核引入总线.设备.驱动模型来描述各种总线(PCI.USB.I2C.SPI)与外围设备及其驱动之间的关系. 2. 在Linux内核中,总线用bus_type结构来描述,定义于文件 ...
- 解决运行vue项目的报错This relative module was not found:
运行vue项目出现这样的报错. This relative module was not found: * ../../assets/img/spot.png !./src/components/on ...