struts首页新闻跳转问题

本文详细介绍了如何使用Struts框架为首页准备数据,通过index.html中的<meta>标签实现自动跳转到指定Action,进而获取并展示所需数据。

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

    struts的机制页面的数据准备需要响应一个action,这样的情况下如何为首页准备数据呢?

    在struts的自己发布的example提供了一种机制:

    最重要依据就是在index.html里加入

<meta http-equiv="Refresh" content="0;URL=./welcome.do" />

    具体如下    

    首先,web.xml里配置:

<welcome-file-list>        
    <welcome-file>index.html</welcome-file>      
</welcome-file-list>

    然后在index.html配置

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta name="generator" content="HTML Tidy for Windows (vers 1st July 2003), see www.w3.org" />
  <meta http-equiv="Refresh" content="0;URL=./welcome.do" />

  <title></title>
</head>

<body>
</body>
</html>

    然后响应到struts-config.xml,

<action-mappings
            type="org.apache.struts.webapp.examples.CustomActionMapping">
        <action path="/welcome" forward="/welcome.jsp">
            <set-property property="example" value="EXAMPLE"/>
        </action>
    </action-mappings>

    这样可以在Action里配置了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值