javaEE_maven_struts2_tomcat_first
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的更多相关文章
- spring4+hibernate4+struts2环境搭建
tomact配置请查看下面的文章 javaEE_maven_struts2_tomcat_first http://www.cnblogs.com/luotuoke/p/4543686.html po ...
随机推荐
- Java常量池详细说明
java常量池技术 java中的常量池技术,是为了方便快捷地创建某些对象而出现的,当需要一个对象时,就可以从池中取一个出来(如果池中没有则创建一个),则在需要重复创建相等变量时节省了很多时间.常量池 ...
- [luogu1627 CQOI2009] 中位数 (乱搞)
传送门 Solution 好水的题(ーー;) Code //By Menteur_Hxy #include <map> #include <queue> #include &l ...
- Python学习笔记之模块与包
一.模块 1.模块的概念 模块这一概念很大程度上是为了解决代码的可重用性而出现的,其实这一概念并没有多复杂,简单来说不过是一个后缀为 .py 的 Python 文件而已 例如,我在某个工作中经常需要打 ...
- Golang - 开篇必须吹牛逼
目录 Golang - 开篇必须吹牛逼 Go牛逼吗 安装环境 Golang - 开篇必须吹牛逼 (1)我们为什么要学 高并发 深度 || 广度 (2)go学习思路和目标 多打多练 掌握go语言 做一个 ...
- 只允许一个 <configSections> 元素。它必须是根 <configuration> 元素的第一个子元素- HTTP Error 500.19
这还是我第一次遇到这个错误,以前都没太注意配置文件中元素的放置顺序.这次在调试一个ASP.NET MVC项目的时候,突然就爆出HTTP Error 500.19错误,提示无法访问请求的页面,因为该页的 ...
- 洛谷 P2010 回文日期
Noip2016普及组T2 题目描述 在日常生活中,通过年.月.日这三个要素可以表示出一个唯一确定的日期. 牛牛习惯用8位数字表示一个日期,其中,前4位代表年份,接下来2位代表月 份,最后2位代表日期 ...
- Swift中文教程(二)基本运算符
1.基本运算符 运算符是一种特定的符号或表达式,用来检验.改动或合并变量.比如,用求和运算符+能够对两个数字进行求和(如let i = 1 + 2):略微复杂一点的样例有逻辑与操作符&& ...
- GNUPlot绘制曲线
发现gnuplot在mac上编译安装相当方便,在线下为了測试java老堆和lucene索引大小,须要绘制两条线,可是直接点连的线很难看,所以后面使用贝塞尔曲线. 脚本例如以下: #! /usr/loc ...
- nyoj-20-吝啬的国度(深搜)
吝啬的国度 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描写叙述 在一个吝啬的国度里有N个城市.这N个城市间仅仅有N-1条路把这个N个城市连接起来.如今,Tom在第S号城市 ...
- Ralink5350开发环境搭建
一.安装虚拟机(Oracle VM VirtualBox 或 VMware Workstation) 二.在虚拟机中安装linux操作系统(当前使用的是Ubuntu1204桌面版) 三.配置linu ...