简体   繁体   English

JAVA JSP也包括JSP和响应

[英]JAVA JSP include JSP and response too

I would like to include an jsp and (separate) response with it too. 我也想包括一个jsp和(单独的)响应。

include: 包括:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <div><%@include file="content.jsp" %></div>
    </body>
</html>

and this is content.jsp: 这是content.jsp:

<p>${message}</p>

Message is a text from database. 消息是来自数据库的文本。 eg.: "Hello!" 例如:“你好!”

Responses: url: / 回应:网址:/

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <div>Hello!</div>
    </body>
</html>

url: /hello 网址:/ hello

<p>Hello!</p>

So my ask is how I recycle a jsp file if it is contain parameters? 所以我的问题是,如果包含参数,如何回收一个jsp文件?

So my ask is how I recycle a jsp file if it is contain parameters? 所以我的问题是,如果包含参数,如何回收一个jsp文件?

  1. Using an efficient template system, fragmenting your jsp and create pages with single include. 使用高效的模板系统,将您的jsp分割成碎片,并创建包含单个include的页面。

  2. Or you use 或者你用

      <% String message1 = request.getParameter("message"); %> <jsp:include page="...." > <jsp:param name="param1" value=<%=message1%> > </jsp:param> </jsp:include> 
  3. Or you can copy and paste and using controller to manage the parameters. 或者,您可以复制和粘贴并使用控制器来管理参数。

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

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