StrutsII学习笔记_ HelloWorld

本文详细介绍如何使用MyEclipse 7.5搭建Struts2项目环境,包括Apache Struts2 2.2的下载与配置、Java 1.6环境准备、Struts.xml与Web.xml的配置步骤,并介绍了启动项目的具体方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

apache 下载Struts2  2.2

Oracle Sun 下载Java  1.6

配置MyEclipse 7.5

 

打开下载Struts2文件的例子程序   blank war文件  (WinRar文件打开)

 

Struts.xml文件拷贝到src文件下

配置如下:

<?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.devMode" value="true" /> <!-- 修改文件后自动部署 -->
<package name="default" namespace="/" extends="struts-default">
        <default-action-ref name="index" />
        <action name="hello_struts">
            <result >
              /hello.jsp
            </result>
        </action>
  </package>

    <!-- Add packages here -->

</struts>

Web.xml增加过滤器

 
    <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>

 

 

添加index.xml文件

 

启动项目:http://localhost:8080/Struts2_0100_Introduction/hello_struts

 

添加Dt校验

 

window   proference     xml cataloges   add     location    URI   HttpAddress

 

 

MyEclipse  修改项目的发布路径

 

Project   proferences  web 修改文本框里面的内容

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值