Struts2.5+eclipse+tomcat8.5配置
来源:互联网 发布:交通组织优化方案 编辑:程序博客网 时间:2024/05/21 10:02
1. 下载struts2.5文件并解压
2. 进入struts-2.5.10.1-all\lib
3.找到下图中的jar包导入到eclipse的web工程下的WIn-INF下的lib文件夹中
4. 配置web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>框架测试</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <!-- struts配置 --> <filter> <filter-name>struts2</filter-name> <filter-class> org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter </filter-class> </filter> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern><!-- 对-ura用 --> </filtermpping></web-app>
5.action类
package test;public class HelloStruts{ public String execute() { System.out.println("执行action"); return "success"; }}
6. 配置struts.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd"> <struts> <package name="test" namespace="" extends="struts-default"> <!-- 包名自定 --> <action name="hellostruts" class="test.HelloStruts" method="execute"> <!-- name: action名称,在jsp页面用 action的name.action访问 --> <!-- class: 实现类 --> <!-- method: 实现的方法 --> <result name="success"><!-- 结果集 ,根据name的值转到不同的页面 --> /test.jsp </result> </action> </package> </struts>
7. 测试页面index.jsp和test.jsp
index.jsp:
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%><%@ taglib prefix="s" uri="/struts-tags"%><!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><s:form action="/hellostruts.action"><!--/actionname . action--!> <s:submit value="Click Here"></s:submit></s:form></body></html>
test.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>Insert title here</title></head><body><h1>Hello Action!</h1></body></html>
web工程目录结构:
0 0
- Struts2.5+eclipse+tomcat8.5配置
- eclipse配置tomcat8.5
- eclipse配置tomcat8.5
- eclipse配置tomcat8.5
- eclipse配置Struts2至Tomcat8.5 全过程搭建
- Tomcat8.5版本在eclipse中的配置
- eclipse安装Tomcat8.5
- tomcat8.5 配置
- Tomcat8.5配置HTTPS
- tomcat8.5配置https
- Tomcat8.5集群配置
- tomcat8.0.14 + struts2.3.24+eclipse-javaEE配置----HelloWorld
- eclipse配置tomcat8.5(注意是8.5)
- Eclipse Tomcat8 配置启动
- Eclipse LUNA配置Tomcat8
- Eclipse 配置tomcat8
- eclipse配置tomcat8
- 应对eclipse不支持Tomcat8和Tomcat8.5或者更高版本
- Android SQLiteDatabase
- Android之JNI DETECTED ERROR IN APPLICATION: illegal class name 'XXX'的错误解决方法
- Zabbix编译安装过程中遇到的问题
- Python for Eclipse
- webxml引申来的
- Struts2.5+eclipse+tomcat8.5配置
- 滚动RecyclerView加载图片时的流畅度优化
- 支付宝的RSA加签验签机制
- 【基础JSP 练习】
- 排序算法-09-排序1 排序 (25分)-第二部分
- selenium 自主登录百度云,新建文件、删除文件及重命名
- c#获取本地IP和MAC地址
- java连接mysql数据的url写法
- Koa2 学习笔记(第一天)