struts2 + spring3 + mybatis3 环境搭建

struts2 + spring3 + mybatis3

1. 框架下载

struts2: http://struts.apache.org/ 下载 struts-2.3.14-all.zip

spring3: http://www.springsource.org/spring-framework 下载 spring-framework-3.2.2-dist.zip

mybatis3: http://code.google.com/p/mybatis/ 下载 mybatis-3.2.2.zip 和 mybatis-spring-1.2.0-bundle.zip

2. 建示例工程

在Eclipse中新建示例工程,步骤就不详述了,我把工程取名为ssm_example。

3. struts2配置

3.1 src下创建struts.xml配置文件

[html] view plaincopyprint?

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE struts PUBLIC
  3. "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
  4. "http://struts.apache.org/dtds/struts-2.0.dtd">
  5. <struts>
  6. <constant name="struts.devMode" value="true" />
  7. <package name="basic" extends="struts-default">
  8. <action name="index" class="cn.ssm.sample.action.IndexAction" method="execute">
  9. <result name="success">/WEB-INF/jsp/Index.jsp</result>
  10. </action>
  11. </package>
  12. </struts>
<?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="basic" extends="struts-default">
		<action name="index" class="cn.ssm.sample.action.IndexAction" method="execute">
			<result name="success">/WEB-INF/jsp/Index.jsp</result>
		</action>
	</package>

</struts>

3.2 修改web.xml

[html] view plaincopyprint?

  1. <filter>
  2. <filter-name>struts2</filter-name>
  3. <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
  4. </filter>
  5. <filter-mapping>
  6. <filter-name>struts2</filter-name>
  7. <url-pattern>/*</url-pattern>
  8. </filter-mapping>
<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>

3.3 从解压的struts-2.3.14-all的lib文件夹下,挑选了必须的和比较常用的jar包,放入WEB-INF/lib的文件夹下

[html] view plaincopyprint?

  1. commons-fileupload-1.2.2.jar
  2. commons-io-2.0.1.jar
  3. commons-lang-2.4.jar
  4. commons-lang3-3.1.jar
  5. commons-logging-1.1.1.jar
  6. commons-logging-api-1.1.jar
  7. freemarker-2.3.19.jar
  8. javassist-3.11.0.GA.jar
  9. ognl-3.0.6.jar
  10. struts2-core-2.3.14.jar
  11. xwork-core-2.3.14.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang-2.4.jar
commons-lang3-3.1.jar
commons-logging-1.1.1.jar
commons-logging-api-1.1.jar
freemarker-2.3.19.jar
javassist-3.11.0.GA.jar
ognl-3.0.6.jar
struts2-core-2.3.14.jar
xwork-core-2.3.14.jar

3.4 建个测试用的IndexAction.java和Index.jsp

[java] view plaincopyprint?

  1. package cn.ssm.sample.action;
  2. import com.opensymphony.xwork2.ActionSupport;
  3. public class IndexAction extends ActionSupport{
  4. @Override
  5. public String execute() throws Exception {
  6. // TODO Auto-generated method stub
  7. return super.execute();
  8. }
  9. }
package cn.ssm.sample.action;

import com.opensymphony.xwork2.ActionSupport;

public class IndexAction extends ActionSupport{

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		return super.execute();
	}

}

[html] view plaincopyprint?

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>Insert title here</title>
  8. </head>
  9. <body>
  10. Hello world!
  11. </body>
  12. </html>
<%@ 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>
	Hello world!
</body>
</html>

3.5 测试struts2

运行服务,在浏览器输入http://localhost:8080/ssm_example/index,如果配置没有错误,那么会出现Hello world!

4. spring3配置

4.1 config/spring下创建applicationContext.xml配置文件

[html] view plaincopyprint?

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
  4. xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xsi:schemaLocation="
  7. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
  8. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  9. http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
  10. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
  11. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
  12. <!-- enable component scanning (beware that this does not enable mapper
  13. scanning!) -->
  14. <context:component-scan
  15. base-package="cn.ssm.sample.action,cn.ssm.sample.service" />
  16. <!-- enable autowire -->
  17. <context:annotation-config />
  18. <!-- enable transaction demarcation with annotations -->
  19. <tx:annotation-driven />
  20. </beans>
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

	<!-- enable component scanning (beware that this does not enable mapper
		scanning!) -->
	<context:component-scan
		base-package="cn.ssm.sample.action,cn.ssm.sample.service" />

	<!-- enable autowire -->
	<context:annotation-config />

	<!-- enable transaction demarcation with annotations -->
	<tx:annotation-driven />

</beans>

4.2 修改web.xml

[html] view plaincopyprint?

  1. <listener>
  2. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  3. </listener>
  4. <context-param>
  5. <param-name>contextConfigLocation</param-name>
  6. <param-value>/WEB-INF/classes/applicationContext.xml
  7. </param-value>
  8. </context-param>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/classes/applicationContext.xml
        </param-value>
	</context-param>

4.3 添加相关jar包

[html] view plaincopyprint?

  1. aopalliance-1.0.jar
  2. spring-aop-3.2.2.RELEASE.jar
  3. spring-beans-3.2.2.RELEASE.jar
  4. spring-context-3.2.2.RELEASE.jar
  5. spring-core-3.2.2.RELEASE.jar
  6. spring-expression-3.2.2.RELEASE.jar
  7. spring-jdbc-3.2.2.RELEASE.jar
  8. spring-tx-3.2.2.RELEASE.jar
  9. spring-web-3.2.2.RELEASE.jar
  10. struts2-spring-plugin-2.3.14.jar
aopalliance-1.0.jar
spring-aop-3.2.2.RELEASE.jar
spring-beans-3.2.2.RELEASE.jar
spring-context-3.2.2.RELEASE.jar
spring-core-3.2.2.RELEASE.jar
spring-expression-3.2.2.RELEASE.jar
spring-jdbc-3.2.2.RELEASE.jar
spring-tx-3.2.2.RELEASE.jar
spring-web-3.2.2.RELEASE.jar
struts2-spring-plugin-2.3.14.jar

4.4 修改struts.xml文件

添加:<constant name="struts.objectFactory" value="spring"></constant>

并且把class="cn.ssm.sample.action.IndexAction"改成class="indexAction"

4.5 修改Action

在IndexAction的类上,加上@Controller,这样Spring就能自动实例化成indexAction对象了。

4.6 测试spring

运行服务,在浏览器输入http://localhost:8080/ssm_example/index,如果配置没有错误,那么依然会出现Hello world!

5. mybatis3配置

5.1 数据库准备

这里采用mysql,下面的sql文来运行。

[sql] view plaincopyprint?

  1. CREATE SCHEMA `ssmsample` DEFAULT CHARACTER SET utf8 ;
  2. CREATE  TABLE `ssmsample`.`user` (`id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(45) NULL, PRIMARY KEY(‘id‘) );
  3. INSERT INTO `ssmsample`.`user` (`id`,`name`) VALUES (1,‘Ethan‘);
CREATE SCHEMA `ssmsample` DEFAULT CHARACTER SET utf8 ;
CREATE  TABLE `ssmsample`.`user` (`id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(45) NULL, PRIMARY KEY(‘id‘) );
INSERT INTO `ssmsample`.`user` (`id`,`name`) VALUES (1,‘Ethan‘);

5.2 修改applicationContext.xml

[html] view plaincopyprint?

  1. <!-- 数据源配置 -->
  2. <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
  3. destroy-method="close">
  4. <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
  5. <property name="url"
  6. value="jdbc:mysql://localhost:3306/ssmsample?useUnicode=true&characterEncoding=utf8"></property>
  7. <property name="username" value="root"></property>
  8. <property name="password" value="admin"></property>
  9. </bean>
  10. <!-- transaction manager, use JtaTransactionManager for global tx -->
  11. <bean id="transactionManager"
  12. class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  13. <property name="dataSource" ref="dataSource" />
  14. </bean>
  15. <!-- define the SqlSessionFactory -->
  16. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  17. <property name="dataSource" ref="dataSource" />
  18. <property name="typeAliasesPackage" value="cn.ssm.sample.dto" />
  19. </bean>
  20. <!-- scan for mappers and let them be autowired -->
  21. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  22. <property name="basePackage" value="cn.ssm.sample.dao" />
  23. </bean>
	<!-- 数据源配置 -->
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
		destroy-method="close">
		<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
		<property name="url"
			value="jdbc:mysql://localhost:3306/ssmsample?useUnicode=true&characterEncoding=utf8"></property>
		<property name="username" value="root"></property>
		<property name="password" value="admin"></property>
	</bean>

	<!-- transaction manager, use JtaTransactionManager for global tx -->
	<bean id="transactionManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>

    <!-- define the SqlSessionFactory -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="typeAliasesPackage" value="cn.ssm.sample.dto" />
    </bean>

    <!-- scan for mappers and let them be autowired -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="cn.ssm.sample.dao" />
    </bean>

5.3 创建和修改相关类

UserMapper.java

[java] view plaincopyprint?

  1. package cn.ssm.sample.dao;
  2. import cn.ssm.sample.dto.User;
  3. public interface UserMapper {
  4. User getUser(int id);
  5. }
package cn.ssm.sample.dao;

import cn.ssm.sample.dto.User;

public interface UserMapper {
	User getUser(int id);
}

UserMapper.xml(和UserMapper.java同目录)

[html] view plaincopyprint?

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="cn.ssm.sample.dao.UserMapper">
  5. <select id="getUser" parameterType="int" resultType="User">
  6. SELECT *
  7. From user where id = #{id}
  8. </select>
  9. </mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="cn.ssm.sample.dao.UserMapper">
	<select id="getUser" parameterType="int" resultType="User">
		SELECT *
		From user where id = #{id}
	</select>
</mapper>

User.java

[java] view plaincopyprint?

  1. package cn.ssm.sample.dto;
  2. public class User {
  3. int id;
  4. String name;
  5. public int getId() {
  6. return id;
  7. }
  8. public void setId(int id) {
  9. this.id = id;
  10. }
  11. public String getName() {
  12. return name;
  13. }
  14. public void setName(String name) {
  15. this.name = name;
  16. }
  17. }
package cn.ssm.sample.dto;

public class User {
	int id;
	String name;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}

IndexSvr.java

[java] view plaincopyprint?

  1. package cn.ssm.sample.service;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.stereotype.Service;
  4. import cn.ssm.sample.dao.UserMapper;
  5. import cn.ssm.sample.dto.User;
  6. @Service
  7. public class IndexSvr {
  8. @Autowired
  9. UserMapper userMapper;
  10. public User getUser(int id) {
  11. return userMapper.getUser(id);
  12. }
  13. }
package cn.ssm.sample.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.ssm.sample.dao.UserMapper;
import cn.ssm.sample.dto.User;

@Service
public class IndexSvr {

	@Autowired
	UserMapper userMapper;

	public User getUser(int id) {
		return userMapper.getUser(id);
	}
}

IndexAction.java

[java] view plaincopyprint?

  1. package cn.ssm.sample.action;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.stereotype.Controller;
  4. import cn.ssm.sample.dto.User;
  5. import cn.ssm.sample.service.IndexSvr;
  6. import com.opensymphony.xwork2.ActionSupport;
  7. @Controller
  8. public class IndexAction extends ActionSupport{
  9. private User user;
  10. public User getUser() {
  11. return user;
  12. }
  13. public void setUser(User user) {
  14. this.user = user;
  15. }
  16. @Autowired
  17. IndexSvr indexSvr;
  18. @Override
  19. public String execute() throws Exception {
  20. user = indexSvr.getUser(1);
  21. return super.execute();
  22. }
  23. }
package cn.ssm.sample.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import cn.ssm.sample.dto.User;
import cn.ssm.sample.service.IndexSvr;

import com.opensymphony.xwork2.ActionSupport;

@Controller
public class IndexAction extends ActionSupport{

	private User user;

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Autowired
	IndexSvr indexSvr;

	@Override
	public String execute() throws Exception {
		user = indexSvr.getUser(1);
		return super.execute();
	}

}

index.jsp

[html] view plaincopyprint?

  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>Insert title here</title>
  8. </head>
  9. <body>
  10. Hello world! ${user.name }
  11. </body>
  12. </html>
<%@ 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>
	Hello world! ${user.name }
</body>
</html>

5.4 添加jar包

[html] view plaincopyprint?

  1. commons-dbcp-1.4.jar
  2. commons-pool-1.6.jar
  3. mybatis-3.2.2.jar
  4. mybatis-spring-1.2.0.jar
  5. mysql-connector-java-5.1.13-bin.jar
commons-dbcp-1.4.jar
commons-pool-1.6.jar
mybatis-3.2.2.jar
mybatis-spring-1.2.0.jar
mysql-connector-java-5.1.13-bin.jar

5.5 测试ssm

运行服务,在浏览器输入http://localhost:8080/ssm_example/index,如果配置没有错误,那么依然会出现Hello world!Ethan

时间: 2024-10-19 07:01:04

struts2 + spring3 + mybatis3 环境搭建的相关文章

Struts2+Spring3+Mybatis3开发环境搭建

本文主要介绍Struts2+Spring3+Mybatis3开发环境搭建 Struts和Spring不过多介绍. MyBatis 是支持普通 SQL 查询,存储过程和高级映射的优秀持久层框架.MyBatis 消除了几乎所有的 JDBC 代码和参数的手工设置以及结果集的检索.MyBatis 使用简单的 XML 或注解用于配置和原始映射,将接口和 Java 的 POJOs(Plan Old Java Objects,普通的 Java 对象)映射成数据库中的记录. 环境: Struts-2.3.14

如何自学Struts2之Struts2架构和环境搭建[视频]

如何自学Struts2之Struts2架构和环境搭建[视频] 之前写了一篇"打算做一个视频教程探讨如何自学计算机相关的技术",昨天晚上刚好有点时间,先做两个视频: http://v.youku.com/v_show/id_XODkyMTczMzMy.html 明天就回家过年了,家里没网络,等回来上海再继续弄吧,先给大家拜个早年,祝新春快乐,阖家幸福,事事如意!

struts2+Hibernate4+spring3+EasyUI环境搭建之一

SSHE环境搭建第一步:安装软件(经验:安装软件路径最好不要有空格.括弧.中文等特殊符号)1.Jdk72.tomcat73.maven34.MyEclipse10.7 破解及优化设置(设置本地安装jdk7+maven+tomcat7+常用插件)或eclipse+常用插件5.oracle+plsql或mysql+navicat 第二步:整合搭建1.myeclipse创建web工程 挑勾Standard Maven JEE Project; 创建完成工程后初始化设置: 检查项目编码:选中项目,按下组

struts2 框架 的环境搭建 与配置

一,Struts2简介: 1,来由:Struts(金属支架),在程序中表示起支撑作用的通用程序代码,Struts2是在Struts1框架的基础上融合了WebWork优秀框架升级得到的. 2,解释:Struts2框架是一个轻量级的MVC流程框架,轻量级是指程序的代码不是很多,运行时占用的资源不是很多,MVC流程框架就是说它是支持分层开发,控制数据的流程,从哪里来,到那里去,怎么来,怎么去的这样一个框架: 二.环境搭建 1, 导入jar包 2导入web.xml文件,改配置 <?xml version

struts2+Hibernate4+spring3+EasyUI环境搭建之五:引入jquery easyui

1.下载jquery easyui组件     http://www.jeasyui.com/download/index.php 2.解压 放到工程中  如图 3.jsp引入组件:必须按照如下顺序 <script type="text/javascript" src="jslib/jquery-easyui-1.4.4/jquery.min.js"></script> <!--jquery文件 --><script typ

Struts2+Spring3+MyBatis3整合以及Spring注解开发

 分类: Web(2)  版权声明:本文为博主原创文章,未经博主允许不得转载. 最近在做一个SpringMVC+spring+MyBatis的项目,突然想起以前自己要搭建一个Struts2+Spring+IBatis的框架,但是没成功,正好看见培训时候老师给的千里之行的开源项目.于是将这个项目提供的SQL加入到了自己的数据库中(所以数据和项目名用的是qlzx),打算以后做练习的时候用这个数据库.那么接下来问题来了(不要说某翔或者不约,不是那个问题):我有了数据库和数据,想要搭建一个网站,该怎么做

Struts2+Spring+Hibernate环境搭建

struts-2.3.20 spring-4.1.4 hibernate-4.3.8 slf4j-1.7.10 1.在MySQL中建立数据库 mysql> create database myoa default character set utf8 2.在MyEclipse中建立Web Project 在项目上右键-Properties,设置编码为UTF-8. 3.配置Struts2 拷贝jar包(依照示例,另aopalliance.jar). 在web.xml中写入Struts Filter

使用Maven搭建Struts2+Spring3+Hibernate4的整合开发环境

做了三年多的JavaEE开发了,在平时的JavaEE开发中,为了能够用最快的速度开发项目,一般都会选择使用Struts2,SpringMVC,Spring,Hibernate,MyBatis这些开源框架来开发项目,而这些框架一般不是单独使用的,经常是Struts2+Spring3+Hibernate.SpringMVC+Spring+Hibernate.SpringMVC+Spring+Mybatis这几种组合中的一种,也就是多个框架配合起来使用.今天来总结一下如何使用Maven搭建Struts

Maven搭建Struts2+Spring3+Hibernate4框架

做了三年多的JavaEE开发了,在平时的JavaEE开发中,为了能够用最快的速度开发项目,一般都会选择使用Struts2,SpringMVC,Spring,Hibernate,MyBatis这些开源框架来开发项目,而这些框架一般不是单独使用的,经常是Struts2+Spring3+Hibernate.SpringMVC+Spring+Hibernate.SpringMVC+Spring+Mybatis这几种组合中的一种,也就是多个框架配合起来使用.今天来总结一下如何使用Maven搭建Struts