简体   繁体   English

如何在Java / Spring中将JSP文件包含在逻辑中?

[英]How to include jsp file with logic in java/spring?

I wonder if is is a way to include jsp file like: in page.jsp: 我想知道是否是在page.jsp中包含jsp文件的方法:

include: header.jsp

but with a logic of this file, I'm a front-end developer so in Angular i can create component that contains html template and js file with logic inside, and by using component name like 但是使用这个文件的逻辑,我是一个前端开发人员,所以在Angular中,我可以创建包含HTML模板和js文件且内部具有逻辑的组件,并且可以使用类似组件的名称

<my-header></my-header>

i can #1 include html code, and #2 automatically invoke logic of this template, I heard about 我可以#1包含html代码,并且#2自动调用此模板的逻辑,我听说

<jsp:include>

but probably it can't do what I want. 但可能无法满足我的要求。

You can use Apache Tiles framework to achieve this. 您可以使用Apache Tiles框架来实现此目的。

https://tiles.apache.org/framework/ https://tiles.apache.org/framework/

Thymeleaf ( or Tiles ) are better bets than JSP. Thymeleaf(或Tiles)比JSP更好。 As a general rule you shouldn't include much logic unrelated to whats absolutely necessary for display purposes in the front end. 通常,您不应该在前端包含太多与显示目的绝对必要无关的逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM