如何执行struts2动作,这些动作必须在主JSP中 [英] How can you execute struts2 actions that need to be in the main opening JSP

查看:53
本文介绍了如何执行struts2动作,这些动作必须在主JSP中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在主页(索引)上访问网站时,它必须加载通过操作获得的信息.我一直在做一些研究,但我看不出该怎么做.有人可以给我提示吗?

When accessing the website at the main (index) page it has to load information that comes through actions. I have been doing some research but I do not see really clear how to do it. Can anybody give me a hint about this?

我所看到的只是通过JavaScript.如果还有其他方法可以解决,谢谢您.

All I have seen is through JavaScript. If there is any other way to do it I would appreciate if you can explain it.

推荐答案

启动应用程序,而不是像这样直接指向JSP:

To start your application, instead of pointing directly on a JSP like this:

http://localhost:8080/myapp/index.jsp

您可以指向在索引JSP上转发的操作.

You can point to an action which forwards on index JSP.

http://localhost:8080/myapp/

Web.xml

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

Index.html(放在webContent下,这只是一个示例):

Index.html (placed under webContent, this is just an example):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="Refresh" CONTENT="0;URL='start.do'">
<TITLE>My application</TITLE>
</HEAD>
</HTML>

struts-config.xml

struts-config.xml

    <action name="start" class="com.myapp.startAction" method="init">
                <result name="success">/main.jsp</result>
    </action>

这可以是另一种方式,特别是对于struts2(例如,使用index.jsp代替@coding_idiot建议的index.html).但这应该可行.

It can be other way to do this, specially with struts2 (for instance using an index.jsp instead of index.html as suggested by @coding_idiot). But this should work.

这篇关于如何执行struts2动作,这些动作必须在主JSP中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆