1.在eclipse中新建web项目,命名testJ2EE
2.下载struts2,将struts-2.xx\lib目录下的freemarker-x.jar,ognl-x.jar,struts2-core-x.jar,xwork-x.jar,commons-logging-x.jar,commons-fileupload-x.jar
拷贝到WebRoot/WEB-INF/lib下(struts2的最下依赖包)
3.在web.xml中配置struts2
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
4.在src下添加struts2的配置文件struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="struts" extends="struts-default">
<action name="testStruts2" class="testJ2EE.test.TestStruts2" method="test">
<result name="success">/pages/test_struts2.jsp</result>
</action>
</package>
</struts>
5.struts2配置完成,添加测试struts2是否配置成功的类
TestStruts2.java
package testJ2EE.test;
public class TestStruts2 {
public String test(){
return "success";
}
}
添加WebRoot/pages/test_struts2.jsp
<%@ 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>success</title>
</head>
<body>
struts2 整合成功
</body>
</html>
添加配置文件struts.xml
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
6.部署到tomcat,在浏览器中输入http://localhost:8081/testJ2EE/testStruts2.action
成功!!!
分享到:
相关推荐
配置struts2常见错误,包括引架包不全引起的异常信息,
在Eclipse中配置Struts2项目(html)手把手教会你 如何在Eclipse中配置Struts2。 struts2 标签库介绍(html)对Struts2的标签做了详细的介绍让你轻松掌握Struts2的标签。 STRUTS2学习文档.pdf 对Struts2的一些配置...
配置struts2需要的资源包,去掉了不需要的一些包。
配置struts2 - 风轻云淡 配置struts2 - 风轻云淡
JAVA Eclipse 配置Struts2
此为MyEclipse下Struts2的配置使用文档,附件包括配置步骤文档及源码,文档为本人学习struts2配置一步一步所写,完全为个人对struts2的学习理解,如有不正确的地方,请留言批评指正,谢谢!附件包含项目源码,为本人...
不用开发工具徒手配置会遇到很多问题。像Tomcat虚拟路径的问题、Tomcat报错的问题。其实搞明白后挺简单的,按着文档一步步来可以解决所有Tomcat报错的问题~~
自己总结的struts2的配置步骤!让我们菜鸟们起步
MyEclipse教你如何配置struts2
NULL 博文链接:https://zhaojun1717.iteye.com/blog/1037136
Eclipse中配置Struts2项目指南 ,介绍Eclipse中如何配置Struts2项目
配置Struts2开发环境,“公欲善其事,必先利其器”,笔者选择的工具软件主要有两类:Java EE应用服务器和java开发工具,采用Glassfish作为应用服务器、Eclipse作为java开发工具,本章将要帮助读者一步一步地搭建起...
struts2配置过滤器 示例代码
java三大框架之一的,配置Struts2所需的所有jar包
安装配置JAVAEclipse配置Struts2项目.pdf
在MyEclipse2013中使用图形界面快速配置struts2的操作方法,自己动手做的练习,对Java Web编程入门者有用。本人已测试通过,详细操作内附有图形说明,有源码和发布文件。
最详细eclipse配置struts2最近下载了最新的struts 2.06,在使用其中附带的例子时,在配置上遇到了一些问题。 经过很多次的努力后,终于配置成功。现在把配置过程写出来供大家参考!
MyEclipse下配置Struts2[整理].pdf
主要是用spring配置struts2文件
配置Struts配置Struts配置Struts配置Struts配置Struts配置Struts