首页 > 其他分享 >使用MyEclipse2022-1搭建Maven版本的Struts2-3项目

使用MyEclipse2022-1搭建Maven版本的Struts2-3项目

时间:2022-10-30 02:02:59浏览次数:74  
标签:provided MyEclipse2022 struts Maven Struts2 glassfish 3.0 org javax

MyEclipse 2022.1

下载

推荐直接到官网下载,不要去其他地方下载,避免一些被加载了病毒的安装包。

备用下载与破解包下载:

链接: https://pan.baidu.com/s/1gPlSLEJa1jhpQhrvWhI3-g 请发邮件至 [email protected] 获取提取码

破解

解压查看 readme.txt

搭建 struts2.3 的 Maven 版项目

struts 2.3.37 下载

https://archive.apache.org/dist/struts/2.3.37/struts-2.3.37-all.zip

备注:使用 Eclipse 2022.9 也可以。

新建项目

注意版本选择:

JavaEE:6,Web3.0

JDK:1.7

JSTL:1.2.1

后面的 Tomcat 我们使用 Tomcat7

勾上Maven支持

配置 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>struts23m</groupId>
	<artifactId>struts23m</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>war</packaging>
	<name>struts23m</name>
	<description />
	<properties>
		<webVersion>3.0</webVersion>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.glassfish</groupId>
			<artifactId>bean-validator</artifactId>
			<version>3.0-JBoss-4.0.2</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.glassfish</groupId>
			<artifactId>javax.enterprise.deploy</artifactId>
			<version>3.0.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.glassfish</groupId>
			<artifactId>javax.jms</artifactId>
			<version>3.0.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.glassfish</groupId>
			<artifactId>javax.management.j2ee</artifactId>
			<version>3.0.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.eclipse.persistence</groupId>
			<artifactId>javax.persistence</artifactId>
			<version>2.0.0</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.glassfish</groupId>
			<artifactId>javax.resource</artifactId>
			<version>3.0.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.glassfish</groupId>
			<artifactId>javax.security.auth.message</artifactId>
			<version>3.0.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.glassfish</groupId>
			<artifactId>javax.security.jacc</artifactId>
			<version>3.0.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.glassfish</groupId>
			<artifactId>javax.servlet</artifactId>
			<version>3.0.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.glassfish</groupId>
			<artifactId>javax.servlet.jsp</artifactId>
			<version>3.0.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.glassfish</groupId>
			<artifactId>javax.servlet.jsp.jstl</artifactId>
			<version>3.0.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.xml.bind</groupId>
			<artifactId>jaxb-api-osgi</artifactId>
			<version>2.2.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.ws.rs</groupId>
			<artifactId>jsr311-api</artifactId>
			<version>1.1.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.glassfish.web</groupId>
			<artifactId>jstl-impl</artifactId>
			<version>1.2</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.mail</groupId>
			<artifactId>mail</artifactId>
			<version>1.4.3</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.xml</groupId>
			<artifactId>webservices-api-osgi</artifactId>
			<version>2.0.1</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.jboss.weld</groupId>
			<artifactId>weld-osgi-bundle</artifactId>
			<version>1.0.1-SP3</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.glassfish.web</groupId>
			<artifactId>javax.servlet.jsp.jstl</artifactId>
			<version>1.2.1</version>
		</dependency>

		<!-- struts2 -->
		<dependency>
			<groupId>org.apache.struts</groupId>
			<artifactId>struts2-core</artifactId>
			<version>2.3.37</version>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-war-plugin</artifactId>
				<version>3.2.3</version>
				<configuration>
					<failOnMissingWebXml>false</failOnMissingWebXml>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

登录页面 login.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Struts2.3 Login</title>
</head>
<body>
	<form action="login.action">
		username:<input type="text" name="username" /><br /> 
		password:<input type="password" name="password" /><br /> 
		<input type="submit" value="submit" />
	</form>
</body>
</html>

struts.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="struts2" extends="struts-default">
		<action name="login" class="space.terwer.LoginAction">
			<result name="success">/result.jsp</result>
		</action>
	</package>

</struts>

登录逻辑处理类 LoginAction.java

package space.terwer;

public class LoginAction {
	private String username;
	private String password;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String execute() {
		return "success";
	}
}

结果显示页面 result.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Struts2.3 Result</title>
</head>
<body>
	username:${requestScope.username}<br /> 
	password:${requestScope.password }
</body>
</html>

部署并启动Tomcat

备注

使用 MyEclipse Tomcat9.0​ 或者自己配置 Tomcat7​ 运行都可以。推荐使用前者,部署更便捷。成功启动可以看到类似下面的启动日志:

10月 30, 2022 1:23:52 上午 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Parsing configuration file [struts-default.xml]
10月 30, 2022 1:23:53 上午 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Unable to locate configuration files of the name struts-plugin.xml, skipping
10月 30, 2022 1:23:53 上午 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Parsing configuration file [struts-plugin.xml]
10月 30, 2022 1:23:53 上午 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Parsing configuration file [struts.xml]

页面效果:

标签:provided,MyEclipse2022,struts,Maven,Struts2,glassfish,3.0,org,javax
From: https://www.cnblogs.com/tangyouwei/p/use-myeclipse20221-to-build-the-maven-version-of-the-

相关文章

  • 使用MyEclipse2022-1搭建Maven版本的Struts2-3项目
    MyEclipse2022.1下载推荐直接到官网下载,不要去其他地方下载,避免一些被加载了病毒的安装包。备用下载与破解包下载:链接:https://pan.baidu.com/s/1gPlSLEJa1jhpQhrvWh......
  • 使用MyEclipse2022-1搭建Maven版本的Struts2-3项目
    MyEclipse2022.1下载推荐直接到官网下载,不要去其他地方下载,避免一些被加载了病毒的安装包。备用下载与破解包下载:链接:https://pan.baidu.com/s/1gPlSLEJa1jhpQhrvWh......
  • 使用MyEclipse2022-1搭建Maven版本的Struts2-3项目
    MyEclipse2022.1下载推荐直接到官网下载,不要去其他地方下载,避免一些被加载了病毒的安装包。备用下载与破解包下载:链接:https://pan.baidu.com/s/1gPlSLEJa1jhpQhrvWh......
  • 使用MyEclipse2022-1搭建Maven版本的Struts2-3项目
    MyEclipse2022.1下载推荐直接到官网下载,不要去其他地方下载,避免一些被加载了病毒的安装包。备用下载与破解包下载:链接:https://pan.baidu.com/s/1gPlSLEJa1jhpQhrvWh......
  • Maven高级
    Maven高级今日目标理解并实现分模块开发能够使用聚合工程快速构建项目能够使用继承简化项目配置能够根据需求配置生成、开发、测试环境,并在各个环境间切换运行了解......
  • Jenkins配置JDK和Maven
    一、进入全局工具配置   二、新增JDK      三、登录oracle账号密码账号密码已经给你们准备好了:账号:[email protected]密码:Oracle123   ......
  • Gradle 简单介绍以及与 Maven 项目的互相转化
    gradle简单介绍gradle安装和maven的安装类似,解压设置GRADLE_HOME即可。gradle核心——project&taskGradle里的几乎任何东西都是基于两个基础概念:project&task。G......
  • AS 发布aar到阿里云 自建的Maven库
    阿里云maven:https://packages.aliyun.com/maven 本地配置:使用的是maven-publish插件applyplugin:'maven-publish'afterEvaluate{publishing{p......
  • Struts2-001浅析
    Struts2是一个基于MVC设计模式设计模式的Web应用框架应用框架,它本质上相当于一个servlet,在MVC设计模式中,Struts2作为控制器(Controller)来建立模型与视图的数据交互。Stru......
  • Java — Maven安装配置(windows)
    #MAVEN下载、安装、配置环境变量1、下载地址:(​​http://maven.apache.org/download.cgi​​)2、安装(直接解压)3、配置环境变量M2_HOMEpath4、验证(出现错误则有可能是你的JAVA_......