1、在intellij Idea上新建Maven项目,输入相应的groupId,artifactId,项目名称:
2、在项目的pom文件中,引入struts2的核心依赖struts2-core:
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.24.1</version>
3、在java文件夹下,新建struts2.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>
</struts>
4、点击F4 或右击项目,点击Open Module Setting,如下图:
5、给项目添加web框架,点击Modules,然后点击绿色加号,在FrameWork选择Web:
6、为项目添加struts2模板,点击Facets
7、添加项目输出的jar包
8、在web下新增index.jsp文件,内容如下:
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2015/12/29
Time: 13:52
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title></title>
</head>
<body>
Hello World
</body>
</html>
9、配置tomcat,点击Run下的Edit Configuration,命名,然后添加Deployment:
10、启动tomcat,在浏览器中输入http://localhost:8080/