前面已经准备好了Struts-2.3.15,现在就可以直接搭建Struts2的工程了。前面http://blog.csdn.net/huangchnegdada/article/details/9179041有对Struts-2.3.15的准备工作的详述。

首先打开MyEclispe新建一个Web Project,名字就叫Struts2_0100_Introduction,接下来就是配置Struts2的框架:

然后解压E:\Study Tools\Struts2\struts-2.3.15\apps\下的struts2-blank.war

里面有struts的最基本的配置,首先找到E:\Study Tools\Struts2\struts-2.3.15\apps\struts2-blank\WEB-INF下面的web.xml文件,将其拷贝到工程下的WEB-INF下面。web.xml文件中的代码如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" 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.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter> <filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <welcome-file-list>
<welcome-file>hello.jsp</welcome-file>
</welcome-file-list> </web-app>

然后将E:\Study Tools\Struts2\struts-2.3.15\apps\struts2-blank\WEB-INF\classes下的struts.xml文件考到工程的src文件夹中。

最后工程的结构如下:

struts中的文件代码如下:

<?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>
<!--
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="true" /> <package name="default" namespace="/" extends="struts-default"> <default-action-ref name="index" /> <global-results>
<result name="error">/error.jsp</result>
</global-results> <global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings> <action name="index">
<result type="redirectAction">
<param name="actionName">HelloWorld</param>
<param name="namespace">/example</param>
</result>
</action>
</package> <include file="example.xml"/>
-->
<!-- 此段代码非常关键,它可以让你在修改代码后,不需要重新启动服务器 -->
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default"> <default-action-ref name="index" />
<!-- 全局的错误页面 -->
<global-results>
<result name="error">/error.jsp</result>
</global-results> <global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings> <action name="hello_struts">
<result>
/hello.jsp
</result>
</action>
</package>
<!-- Add packages here --> </struts>

将此项目部署起来后,在Web Brower中输入:http://localhost:8080/Struts2_0100_Introduction/hello_struts后会出现下面结果,,就说明成功了。

Struts2第一个工程helloStruts极其基本配置的更多相关文章

  1. Struts2第一天

    Struts2第一天 整体课程安排:3天知识点+2天练习 第一天:入门(action和result结果集)--一般的请求+响应 第二天:请求数据处理相关(参数接收.类型转换.合法性校验.国际化) 第三 ...

  2. Struts2 框架使用 核心以及其他详细配置

    因为在使用SSH框架的过程,关于struts2的配置比较繁琐,所以做个总结. 一.导入并且关联其他XML 1.   因为在核心配置文件(Struts2.xml)中,如果存在很多需要配置的Action项 ...

  3. 用Firefly创建第一个工程

    原地址:http://blog.csdn.net/uxqclm/article/details/10382097 安装完成之后,在python script包中就存在 firefly-admin的工具 ...

  4. MyGui笔记(1)建立第一个工程

    记录下学习 MyGui的一些笔记,从建立第一个工程开始. 步骤: 1.右键MYGUI解决方案,添加→新建项目,选择“Win32 项目”,名称为:TestHello.下一步,勾选“空项目”. 2.设置工 ...

  5. struts2拦截器interceptor的三种配置方法

    1.struts2拦截器interceptor的三种配置方法 方法1. 普通配置法 <struts> <package name="struts2" extend ...

  6. tomcat不用工程名访问怎么配置?

    tomcat不用工程名访问配置,直接用域名访问 在 tomcat6的安装路径下,D:\Tomcat-6\conf,修改server.xml文件 编辑Host节点, <Host appBase=& ...

  7. Annotation 的第一个工程

    一.什么是 Annotation? java.lang.annotation,接口 Annotation.对于Annotation,是Java5的新特性,JDK5引入了Metadata(元数据)很容易 ...

  8. hibernate 的第一个工程

    一.什么是Hibernate? Hibernate 是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一个全自动的orm框架,hiber ...

  9. SSH(Struts2+Spring4+Hibernate4)框架教程之配置篇

    SSH(Struts2+Spring4+Hibernate4)框架教程之配置篇 - 若明天不见 - 博客频道 - CSDN.NEThttp://blog.csdn.net/why_still_conf ...

随机推荐

  1. OpenGL框架+QT版

    原地址:http://blog.chinaunix.net/uid-25799257-id-3498005.html 之前一直做地图的算法,没什么时间学习opengl,之前看nehe_OpenGL.c ...

  2. 基于visual Studio2013解决C语言竞赛题之1084完全平方数

        题目 解决代码及点评 /************************************************************************/ /* ...

  3. PNG 文件结构

    PNG图像文件介绍 PNG图像文件格式 PNG是可携式网络图像(portable network graphics)的英文缩写.PNG是从网络上开始发展的,目的是替代GIF和JPG格式,PNG图像文件 ...

  4. OCP-1Z0-051-题目解析-第33题

    33. You want to create an ORD_DETAIL table to store details for an order placed having the following ...

  5. EL表达式(1)

    JSP页面中支持使用EL表达式,EL全名为Expression Language.EL表达式的主要作用有: ① 获取数据: ② 执行运算: ③ 使用EL表达式的11大隐式对象: ④ 调用Java方法. ...

  6. 2007LA 3902 网络(树+贪心)

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=283&am ...

  7. 发掘ListBox的潜力(三):显示即时提示(Tips)

    ListBox显示即时提示(Tips) Listbox内容太长时超出Listbox宽度的部分将无法显示,一种解决方法是让Listbox产生横向滚动条,滚动显示内容(见前面的<发掘ListBox的 ...

  8. 14.9.2 Specifying the Row Format for a Table 指定 表的行格式

    14.9.2 Specifying the Row Format for a Table 指定 表的行格式 mysql> SHOW TABLE STATUS\G; *************** ...

  9. 被忽视的TWaver功能(1)

    应客户需求写个Demo,Demo中包括一些经常使用的功能.包括解析JSON数据生成TWaver中的网元和连线.网元右下角带上不同标识的小图标,连线须要是二次曲线.弹出菜单和信息板.跟大家分享下.先上图 ...

  10. Swift - 几种使用数组的数据存储模型

    在iOS游戏开发中,比如2048游戏.有时会需要存储N×N数组的数据模型(如3×3,4×4等).这里我们演示了三种实现方式,分别是:一维数组.仿二维数组.自定义二维数组(即矩阵结构). 功能是根据传入 ...