1 .eclipse中新建项目

后边自己设置,然后完成

2.在pom.xml添加

<dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>3.0-alpha-1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        
         <dependency>
          <groupId>org.apache.struts</groupId>
          <artifactId>struts2-core</artifactId>
          <version>2.3.24</version>
        </dependency>

会看到

3.在web-inf中配置struts2

如下配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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 "
        version="2.5">
    <display-name>sign</display-name>
    
    <filter>    
        <filter-name>struts</filter-name>    
        <filter-class>
            org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter    
        </filter-class>    
        <init-param>    
            <param-name>struts.i18n.encoding</param-name>    
            <param-value>utf-8</param-value>    
        </init-param>    
    </filter>
    
    <filter-mapping>
        <filter-name>struts</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <error-page>
        <error-code>404</error-code>
        <location>/common/404.html</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/common/500.html</location>
    </error-page>
    
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
</web-app>

4.添加对应处理页面

5.配置用maven方式启动tomcat,pom.xml中

<build>
    <finalName>signn</finalName>
     <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat6-maven-plugin</artifactId>
                <version>2.0</version>
                <configuration>
                    <url>http://localhost/manager</url>
                    <path>/sign</path>
                    <port>8010</port>
                    <warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <warSourceDirectory>src\main\webapp</warSourceDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>7</source>
                    <target>7</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.4.2</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>target</directory>
                            <includes>
                                <include>signn</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
        </plugins>
  </build>

6.添加配置文件

<?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.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />
    <constant name="struts.objectFactory" value="spring" />
    <constant name="struts.objectFactory.spring.autoWire" value="name" />
    -->
    <constant name="struts.i18n.encodeing" value="GBK"/>
    <constant name="struts.multipart.maxSize" value="52428800" />
    
    <!-- <include file="struts/struts-common.xml"/> -->
    <package name="user"  namespace="/" extends="struts-default">
        <action name="user" class="com.sign.action.UserAction" method="toUser">
            <result name="SUCCESS">/view/user.jsp</result>
        </action>
    </package>
</struts>

7.写对应的action

7.启动tomcat

8.在浏览器中访问

javaEE_maven_struts2_tomcat_first的更多相关文章

  1. spring4+hibernate4+struts2环境搭建

    tomact配置请查看下面的文章 javaEE_maven_struts2_tomcat_first http://www.cnblogs.com/luotuoke/p/4543686.html po ...

随机推荐

  1. 如何设置div自适应高度

    1.给div添加overflow属性 .div{ width:760px; overflow:hidden; } 2.其他的设置height:auto 等我测试没有效果

  2. layer 使用教程

    http://layer.layui.com/ <!DOCTYPE html><html lang="en"><head> <meta c ...

  3. 通过请求接口的办法获得本设备IP以及IP地址

    获取本设备IP接口(搜狐) http://pv.sohu.com/cityjson?ie=utf-8 result Content: {    "cip": "58.21 ...

  4. elasticsearch Suggester实现搜索建议(八)

    Completion Suggester 智能提示 { "settings": { }, "mappings": { "doc": { &q ...

  5. poj 1274 基础二分最大匹配

    #include<stdio.h> #include<string.h> #define N 300 #define inf 0x3fffffff int mark[N],li ...

  6. caffe Solve函数

    下面来看Solver<Dtype>::Solve(const char* resume_file) solver.cpp template <typename Dtype> v ...

  7. codechef Little Elephant and Bombs题解

    The Little Elephant from the Zoo of Lviv currently is on the military mission. There are N enemy bui ...

  8. C语言遍历文件和文件夹——————【Badboy】

    [cpp] #include #include #include #include #include #include #include #define MAX_PATH_LENGTH 512 #de ...

  9. php简单的连接数据库

    <?php $conn=@mysql_connect("localhost","root","") or die ("no& ...

  10. 项目结构、包、编译为exe!

    一个java源文件里至多有一个public类,该类的名称必须与源文件名称称同样.也能够没有public类.文件名称与随意一个类名一致就可以. 包 类似于cpp的namespace,是对类的再封装,防止 ...