struts 2 在 div 中加载一个页面 [英] struts 2 load a page in div

查看:31
本文介绍了struts 2 在 div 中加载一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的主页的图像,我想知道是否可以在 struts2 中加载所有其他页面,如主页中间的红色 div 中的产品服务设施等.我是 struts 2 的新手,所以我不确定是否有可能,请指出如何做到这一点,我们将不胜感激

更新:根据我从 Rugal 先生那里得到的一些解释,我想出了这段代码,但它不起作用,我的想法已经用完了.我把和 ID 放到红色 div 作为工作场所

 

</td></tr>

<脚本>$('#products').click(function(){$('#workplace').load('pages/products.jsp');});$('#services').click(function(){$('#workplace').load('pages/services.jsp');});$('#facilities').click(function(){$('#workplace').load('pages/facilities.jsp');});$('#contact').click(function(){$('#workplace').load('pages/contact.jsp');});

解决方案

您也可以使用 struts2 磁贴来解决您的问题.使用磁贴创建基本布局.您的布局类似于此 教程中的布局.因此,您所需要的只是将菜单放在布局的标题部分.单击按钮或菜单时,您会调用一个特定的操作,然后调用一个特定的 tile 定义,这将使您相关的 jsp 页面位于中间 :)

i have an image of my home page and i am wondering if it is posssible in struts2 to load all other pages such as products services facilities etc. in the red div in the middle of the home page. im new in struts 2 so im not sure if it is even possible please point me out on how to do this it will be appreciated

UPDATE: with some explanation i got from sir Rugal i came up with this code but its not working im running out of ideas. i put and ID to the red div as workplace

            <div id="navbar">
                <ul>
                    <li><a href="index.jsp">Home</a></li>
                    <li id="products"><a href="#">Products</a></li>
                    <li id="services"><a href="#">Services</a></li>
                    <li id="facilities"><a href="#">Facilities</a></li>
                    <li id="contact"><a href="#">Contact Us</a></li>
                </ul>
            </div>
        </td>
    </tr>
</table>
</div>
<script>
$('#products').click(function(){
    $('#workplace').load('pages/products.jsp');
});
$('#services').click(function(){
    $('#workplace').load('pages/services.jsp');
});
$('#facilities').click(function(){
    $('#workplace').load('pages/facilities.jsp');
});
$('#contact').click(function(){
    $('#workplace').load('pages/contact.jsp');
});
</script>

解决方案

You also can use struts2 tiles for your problem. Create your base layout using tiles. your layout is similar to the layout in this tutorial. So all you need is to have your menu in header part of layout. On click of button or menu youy call a particular action whic inturn call a particular tile definition which will have your concerned jsp page in the middle :)

这篇关于struts 2 在 div 中加载一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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