Eclipse搭建Struts2项目
最近在系统性的学习maven,碰到搭建struts2环境,特此记录一下。
1.创建maven工程
2.添加依赖
pom.xml文件内容如下
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dylan</groupId>
<artifactId>02_maven_struts2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.5.16</version>
</dependency>
</dependencies>
<!--添加JDK插件 -->
<build>
<finalName>02_maven_struts2</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
3.在web.xml中添加struts2核心过滤器
<?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"
version="2.5">
<display-name>02_maven_struts2</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
4.编写Action
package action;
import com.opensymphony.xwork2.ActionSupport;
public class CustomerAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
public String save() throws Exception {
System.out.println("方法执行成功!");
return SUCCESS;
}
}
5.编写success.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>方法执行成功后的页面!</h1>
</body>
</html>
6.配置struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<!-- <constant name="struts.enable.DynamicMethodInvocation" value="true"
/> <constant name="struts.devMode" value="true"></constant> -->
<package name="demo" namespace="/" extends="struts-default">
<action name="customerAction_*" class="action.CustomerAction"
method="{1}">
<result name="success">success.jsp</result>
</action>
</package>
</struts>
6.测试
访问:http://localhost:8080/02_maven_struts2/customerAction_save.action
完整项目下载链接:
https://download.csdn.net/download/indexman/10469572
Eclipse搭建Struts2项目的更多相关文章
- Eclipse搭建maven项目的流程,聚合所有的子模块项目
Eclipse搭建maven项目的流程 2018年03月01日 15:47:03 阅读数:22 1:搭建parent工程,用来聚合所有的子模块项目 2:搭建公共使用的模块common 这里你要点击空白 ...
- Eclipse搭建struts2环境
搭建struts2环境 大的方面分为三步: 1. 加入jar包 2. 在web.xml中配置struts2 3. 添加struts2的配置文件struts.xml 下面是详细步骤: 1. 新建一个Dy ...
- eclipse搭建struts2环境及所遇到的问题
最近几天一直在搭建struts2框架,本身struts2框架的搭建是非常简单的,但不知道为什么最近就是总是报错,报了一大串的错 首先就是每次在类的根路径下创建struts.xml时,就报错,也不知道为 ...
- Eclipse搭建Maven项目并上传SVN备份
本文出自:http://www.cnblogs.com/2186009311CFF/p/7226127.html 背景:近段时间在学着Java,想着用Java做BS的项目.但是项目一遇到问题又要重做, ...
- eclipse 搭建maven项目
最近重新搭建项目把日常用到的东西都记录一下. 创建maven项目(maven4.4以后都自带maven了) 1,创建一个Maven parent 主要是各个项目之间的依赖 使用eclipse 创 ...
- 用eclipse 搭建struts2环境
一,下载struts2对应的jar包,(http://struts.apache.org/download.cgi#struts2514.1),我一般下载struts2.3版本的 二,打开eclips ...
- 转载:eclipse 搭建SSH项目(第二篇,有具体的项目例子)
原文地址:http://blog.csdn.net/yeohcooller/article/details/9316923 读博文前应该注意: 本文提纲:本文通过一个用户注册的实例讲解SSH的整合.创 ...
- 转载:eclipse 搭建SSH项目(第一篇)
第一篇:原文地址:http://blog.csdn.net/aaaaaaaa0705/article/details/6288431(虽然没有具体的例子,不过逻辑性强点,比较容易看懂) SSH框架是最 ...
- (A)eclipse搭建springboot项目入门
网上许多资料都是用idea的,但是我个人用eclipse习惯了,所以就在eclipse里面自己尝试着写了一个hello. 然而项目建好后却迟迟不能访问!!!网上搜了许多资料都不靠谱! 虽然最后能看到h ...
- Eclipse 搭建Struts2
Eclipse版本 Mars Release (4.5.0) Struts版本 struts-2.5.20 下载地址:https://struts.apache.org/download.cgi#st ...
随机推荐
- [转帖]Prometheus-使用python开发exporter
exporter有很多,但想要特定需求的话,还需自行开发.在这里使用python写一个exporter,用于监控/root下的目录数量. 开发exporter需要使用prometheus_client ...
- [转帖]Zookeeper集群搭建(3个节点为例)
Zookeeper集群搭建 1.说明 本文用的linux版本:centos6,准备3台centos6虚拟机,给他们安装zookeeper,每一台的安装过程相同,你也可以安装一台,然后克隆出另外两台.主 ...
- [转帖]rclone将本地文件或文件夹导入minio中
1.背景:公司数据迁移涉及到文件迁移,原有文件服务器没有使用minio,但是现在的新系统使用了minio.所以这就需要我们将文件上传到minio文件服务器中:由于历史文件数据量大,甲方要求可以通过服务 ...
- [转帖]OutOfMemory自动重启程序
OutOfMemory以后程序已经假死,无法再提供服务,最好的做法是dump内存,发送警告,然后重启服务 我的方案:利用at命令延迟启动 但有一个问题,at最多支持分钟操作,也就是说要1分钟以后才能启 ...
- 【译文】IEEE白皮书 6G 太赫兹技术的基本原理 2023版
第一章 简介 太赫兹波是介于微波和光波之间的光谱区域,频率从 0.1THz ~ 10THz 之间,波长在 3mm ~ 30μm 之间.提供大块连续的频带范围以满足对 Tbit/s 内极高数据传输速率的 ...
- 浅谈kafka
作者:京东科技 徐拥 入门 1.什么是kafka? apache Kafka is a distributed streaming platform. What exactly dose that m ...
- ClickHouse(09)ClickHouse合并树MergeTree家族表引擎之MergeTree详细解析
目录 建表 数据存储 主键和索引在查询中的表现 主键的选择 选择与排序键不同的主键 索引和分区在查询中的应用 部分单调主键的使用 跳数索引 可用的索引类型 并发数据访问 列和表的 TTL 列TTL 表 ...
- Spring源码之XML文件中Bean标签的解析1
读取XML文件,创建对象 xml文件里包含Bean的信息,为了避免多次IO,需要一次性读取xml文件中所有bean信息,加入到Spring工厂. 读取配置文件 new ClassPathResourc ...
- Flowable-UI
Flowable-UI 安装 手把手教大家画了这样一个流程图,虽然说它不是特别好用,但是也不是不能用,也能用.好了,那么接下来的话,我们这个就先告一个段落,接下来我要跟大家说的第二个东西的话,就是另外 ...
- python入门之后须掌握的知识点(excel文件处理+邮件发送+实战:批量化发工资条)【二】
相关文章: python处理Excel实现自动化办公教学(含实战)[一] python处理Excel实现自动化办公教学(含实战)[二] python处理Excel实现自动化办公教学(数据筛选.公式操作 ...