Eclipse下struts框架的简单搭建
来源:互联网 发布:有哪些域名交易网站 编辑:程序博客网 时间:2024/06/05 10:19
一、下载Eclipse并安装J2EE模式的IDE
Eclipse地址:http://www.eclipse.org/home/index.php
点击DOWNLOAD
选择下载64BIT
点击DOWNLOAD
不需要任何其他操作,静静等待页面弹出下载框就好,如果没有弹出也可提交邮件地址
双击下载的exe文件,选择Eclispe IDE For Java EE Developers
二、下载struts压缩包
官网地址:http://struts.apache.org/
点击DOWNLOAD下载
选择Full Distribution
解压缩放入自己常用的软件盘中
三、打开Eclipse开始搭建struts简易框架
1、new->Dynamic Web Project
在创建项目的next过程最后,记得勾选Generate web.xml deployment descriptor,系统会在webContent文件夹下自动创建web.xml文件
2、将下载的struts文件夹中的apps文件夹下的案例程序解压缩。
3、将案例程序中的lib文件夹中的jar包复制到Eclipse项目的lib文件夹下面
大部分的时候,使用struts2的web应用并不需要利用到Struts2的全部特性,因此没有必要一次将Struts2解压路径下的JAR文件全部复制到WEB应用的WEB-INF/lib路径下
如果缺少相关的jar包可去struts文件夹中的lib包中获取
4、新增文件
5、HelloWorldAction.java
继承ActionSupport
package com.imooc.action;import com.opensymphony.xwork2.ActionSupport;public class HelloWorldAction extends ActionSupport { @Override public String execute() throws Exception { System.out.println("执行Action"); return SUCCESS; }}
6、struts.xml
头文件因版本不同可能不一样,在struts文件中apps案例中,找到之前解压缩的样例文件,复制该struts.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> <package name="default" namespace="/" extends="struts-default"> <action name="helloworld" class="com.imooc.action.HelloWorldAction"> <result>/result.jsp</result> </action> </package></struts>
7、web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>HelloWorld</display-name> <filter> <filter-name>strust2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> </filter> <filter-mapping> <filter-name>strust2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>
8、result.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><!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=ISO-8859-1"><title>Insert title here</title></head><body> This is result.jsp</body></html>
9、执行程序
10、地址中输入http://localhost:8888/HelloWorld/helloworld.action
8888是Tomcat的端口号,这个在装Tomcat的时候设置的
四、常见错误及解决
1、struts框架中德jar包应该是统一的,各个jar包尽量不能分散获得,即它们的版本号应该相同。不推荐下载最新的struts,应该尽量去找稳定版的下载
2、程序中经常会报错,明明程序没有错,步骤流程也是按照书上或者视频上讲的去做的,但是就是不对。
Eclipse中Project->clean 清除缓存
其中有的教程没有明确说明清楚缓存的意思,大部分人都是在Tomcat下clean,没有效果。
- Eclipse下struts框架的简单搭建
- 使用eclipse简单的搭建ssh框架
- Eclipse搭建简单的Spring框架
- struts框架的搭建
- 一个简单的Struts登录框架搭建教程
- 搭建struts、spring、hibernate框架的简单流程
- eclipse下struts简单示例
- 第一节:简单框架搭建-struts-2.3.15.3
- 利用eclipse简单快速的搭建SSH框架
- 不使用Maven的情况下,搭建Spring+Struts+Hibernate框架 - 项目搭建
- Eclipse下搭建struts、spring、hibernate开发环境 搭建环境
- python下搭建最简单的django框架实例
- 超简单方法搭建Eclipse下的Android NDK
- 练手在eclipse中搭建spring+struts+hibernate开发框架
- 在Eclipse中搭建Struts框架过程详解
- 用eclipse搭建ssh框架 struts spring hibernate
- 用eclipse搭建SSH(struts+spring+hibernate)框架
- struts 2框架项目的搭建
- 微信浏览器中的video
- C++速查
- Java和JavaScript中使用Json方法大全
- Unity网络开发实践
- JS-Math对象
- Eclipse下struts框架的简单搭建
- android string.xml中包含百分号时报错 问题记录
- 实战
- 有史以来最详细的正则表达式入门教程
- Java中的数据类型
- 最简洁的PHP程序员学习路线及建议
- Struts2与Spring3 MVC性能比较 (MVC性能测试)
- 时间工具类详细说明 DateUtils
- Android如何隐藏标题栏