Struts2 开发环境搭建
一.开发环境
eclipse+tomcat+struts-2.2.3
二.新建web项目,并向web项目中加入依赖jar包

三.配置web.xm,向web.xml配置Struts2过滤器
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<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.jsp</welcome-file>
</welcome-file-list>
</web-app>
四.向web项目中新建Action业务控制器
package Action;
import com.opensymphony.xwork2.ActionSupport;
public class indexAction extends ActionSupport {
public String index()
{
return SUCCESS;
}
}
五.配置Struts.xml,配置Action业务控制器到Struts.xml中
<?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" namespace="/" extends="struts-default">
<action name="index" method="index" class="Action.indexAction">
<result >
/hello.jsp
</result>
</action> </package>
<!-- Add packages here -->
</struts>
六.加入jsp视图
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>"> <title>My JSP 'index.jsp' starting page</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>
<form action="index" method="get">
hello word!
</form>
</body>
</html>
七.部署项目到Tomcat中。打开浏览器,输入http://localhost:8080/Project1/index。出现hello word 页面。配置成功。
Struts2 开发环境搭建的更多相关文章
- Struts2开发环境搭建,及一个简单登录功能实例
首先是搭建Struts2环境. 第一步 下载Struts2去Struts官网 http://struts.apache.org/ 下载Struts2组件.截至目前,struts2最新版本为2.3.1. ...
- 1.Struts2简介和Struts2开发环境搭建
一.Struts2简介: 1.什么是Struts2? 著名的SSH三大框架分别为:表现层(Struts).业务逻辑层(Spring),持久化层(Hibernate). Struts2是在WebWork ...
- Struts2开发环境搭建
eclipse配置struts2开发环境: 1.导入jar包:复制Struts\apps\struts2-blank\WEB-INF\lib下的所有jar包到当前项目的lib文件夹下 2.在web.x ...
- Struts2+Spring3+Mybatis3开发环境搭建
本文主要介绍Struts2+Spring3+Mybatis3开发环境搭建 Struts和Spring不过多介绍. MyBatis 是支持普通 SQL 查询,存储过程和高级映射的优秀持久层框架.MyBa ...
- struts2.1笔记05:struts2开发环境的搭建
1.找到开发Struts应用需要使用到的jar文件. 首先我们要在myEclipse中新建一个Web Project,我们这里命名为"struts2".然后我们就要使用jar文件, ...
- MyEclipse中搭建Struts2开发环境
(尊重劳动成果,转载请注明出处:http://blog.csdn.net/qq_25827845/article/details/53205941 冷血之心的博客) 在MyEclipse中如何搭建St ...
- struts2系列(一):struts2入门(struts2的产生、struts2的工作流程、搭建struts2开发环境)
一. struts2的产生 struts1的缺点: 1. ActionForm过多,而且这个ActionForm在很大程度上又和VO(POJO)重复 ...
- spring mvc4.1.6 + spring4.1.6 + hibernate4.3.11 + mysql5.5.25 开发环境搭建及相关说明
一.准备工作 开始之前,先参考上一篇: struts2.3.24 + spring4.1.6 + hibernate4.3.11 + mysql5.5.25 开发环境搭建及相关说明 struts2.3 ...
- Sublime Text 3下C/C++开发环境搭建
Sublime Text 3下C/C++开发环境搭建 之前在Linux Mint 17一周使用体验中简单介绍过Sublime Text. 1.Sublime Text 3安装 Ubuntu.Linux ...
随机推荐
- [置顶] Objective-C ,/,ios,/iphone开发基础:协议(protocol)
protocol协议时为了补充Objective-C 只能单继承的缺陷而增加的一个新功能.Objective-C重所有的方法都是虚方法,所以在oc重也就没有关键字 virtual一说,有了协议可以补充 ...
- 为数据元素DATA Element分配搜索帮助
搜索帮助可以分配给数据元素,程序中可以直接参照该数据元素具体如下: 1. 2. 程序中使用. PARAMETERS:p_vbeln TYPE ZVBELN_01. 3. 效果:
- 【ASP.NET Web API教程】2.1 创建支持CRUD操作的Web API
原文 [ASP.NET Web API教程]2.1 创建支持CRUD操作的Web API 2.1 Creating a Web API that Supports CRUD Operations2.1 ...
- 【Demo 0007】Java基础-类扩展特性
本章学习要点: 1. 掌握static 修饰的类,方法以及变量的功能及用法; 2. 掌握代码块(静态,非静态)的作用以及注意事项: 3. 了解基本数据类 ...
- ajax和json详解
responseText 属性以字符串形式返回HTTP响应. responseXML 属性以XML形式返回HTTP响应. JSON.stringify 函数 (JavaScript) 将 Jav ...
- 记录路径dp-4713-Permutation
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4713 题目大意: 题意同HDU 3092这不过这题要输出路径. 解题思路: 思路同HDU 3092. ...
- 14.2.5.1 Role of the .frm File for InnoDB Tables InnoDB .frm文件的作用
14.2.5.1 Role of the .frm File for InnoDB Tables: 14.2.5.1 Role of the .frm File for InnoDB Tables I ...
- Codeforces Round #249 (Div. 2) A B
C好像就是个模拟.D 是个编码复杂度大的,可是好像也就是枚举三角形,我这会儿准备区域赛,尽量找点思维难度大的,所以昨晚A B 还是去做区域赛题吧..... B 也有点意思 贪心 题意:交换相邻两个位的 ...
- Delphi的VMT的结构图,很清楚
Every Delphi class is defined internally by its vmt—its virtual-method table. The vmt contains a li ...
- cannot run program "git.exe":CreateProcess error=2
在使用android studio从git上check项目的时候报错cannot run program "git.exe":CreateProcess error=2 请检查下面 ...