导航菜单的母版页-使用Spring MVC的部分视图? [英] Master Page for Nav Menu - Partial Views with Spring MVC?

查看:292
本文介绍了导航菜单的母版页-使用Spring MVC的部分视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Spring MVC 3.2.2.我有一个主索引页面,其中包含用于登录/用户信息的标题以及导航菜单和页脚(以及其自己的内容).

I'm using spring mvc 3.2.2. I have a main index page that contains a header for login/user info as well as a navigation menu and a footer (as well as it's own content).

> http://localhost:8080/mywebsite/home/index.jsp

<html>....
<head>...
<body>
   <headerbar>...
   <navmenu>...
   <!-- Content here....-->
   <footer>
<body>

现在,我将添加新的控制器和操作,如何重用页眉/导航菜单和页脚,这样就不必在每个其他页面中添加它了?

Now that I will be adding new controllers and actions how can I reuse the header/nav menu and footer so that I don't have to add it in each additional page?

因此,对于我的用户控制器页面,我要做的就是呈现用户信息,而不必包含header/nav/footer等.

So for my users controller page all I want to have to do is render the user information without having include the header/nav/footer etc.

> http://localhost:8080/mysite/account/user/8585

<!-- Only include the following but have it render as body() where nav menu/footer/header are already included in some partial view or master page -->
<h4>User Account</h2>
<user>${username}</user>
<firstname>${firstname}</firstname>

我该怎么做?

<html>....
<head>...
<body>
   <headerbar>...
   <navmenu>...
     RenderBody?() <!-- Content here from any page include home/index.jsp and account/user....-->
   <footer>
<body>

推荐答案

您需要某种模板引擎来解决此问题,例如

You need some kind of template engine to solve this, for example Apache Tiles

这篇关于导航菜单的母版页-使用Spring MVC的部分视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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