Spring 框架:使用 JSP 文件插入另一个 JSP 文件

Spring Framework: Inserting another JSP file with a JSP file

所以我将我的请求路径设置为 mywebsite.com/project/id/12378912?section=data,它映射到相应的 Controller/Action 和 returns "project/index.jsp"。

在 index.jsp 中,我想检查它是什么部分参数并插入正确的 PartialView 部分(但是...我想转到 Controller/Action 来处理一些逻辑)。这可能吗?

我知道我可以使用 (jsp:include) 并插入另一个 .jsp 页面,但我想转到 Controller/Action(那个 .jsp 页面)到 运行 动态生成该 .jsp 页面的一些逻辑。

在 ASP MVC 中,我们有类似的东西...

@{ Html.RenderAction("_" + (string)ViewData["projectSection"], "Project", new { id = Model.Id }); }

嵌入到 master/bigger 视图容器中。

请求只是 returns html 由 jsp 生成,所以你得到 html 结果然后做你想做的。

<jsp:include page="${request.contextPath}/mvc/project/id/${ project.id }/_data"></jsp:include>

进入网页上的正确位置正是我要找的。此代码片段实际上转到控制器,处理任何逻辑,然后生成视图 --> 输出到 main/parent 页面。