- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个格式良好的“JSP 文档”(“XML 中的 JSP”),当网页生成并发送给用户时,一些换行符被删除。
现在真正奇怪的部分是:显然“主”.jsp 总是所有它的换行符被删除但是对于从主 .jsp 包含的任何后续 .jsp,换行符似乎被随机删除(一些有,其他没有)。
例如,如果我正在查看 Firefox 提供的网页并要求“查看源代码”,我会看到生成的内容。
那么,什么决定何时/如何保留/删除换行符?
这只是我编造的一个例子......你能强制一个 .jsp 来服务这个吗:
<body><div id="page"><div id="header"><div class="title">...
或者这个:
<body>
<div id="page">
<div id="header">
<div class="title">...
?
我认为删除换行符是为了节省带宽,但如果我想保留它们怎么办?如果我想保留与 .jsp 文件中相同的 XML 缩进怎么办?
这可行吗?
编辑
按照 skaffman 的建议,我查看了生成的 .java 文件,“主要”文件没有很多 out.write 但没有一个写制表符或换行符。与该文件相反,我从主 .jsp 中包含的所有文件都有很多行,例如:
out.write("\t...\n");
所以我想我的问题保持不变:是什么决定了如何在输出中包含/删除制表符/空格/换行符?
最佳答案
根据 JSP specification :
JSP.6.2.3 Semantic Model
...
To clearly explain the processing of whitespace, we follow the structure of theXSLT specification. The first step in processing a JSP document is to identify thenodes of the document. Then, all textual nodes that have only white space aredropped from the document; the only exception are nodes in a jsp:text element,which are kept verbatim. The resulting nodes are interpreted as described in thefollowing sections. Template data is either passed directly to the response or it ismediated through (standard or custom) actions.
所以,如果你想保留空白,你需要把想要的部分包裹在<jsp:text>
中。 .
关于java - JSP 文档/JSPX : what determines how tabs/space/linebreaks are removed in the output?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2935093/
我想在 jspx 中使用版权符号,但它不允许我使用 © 。它给我一个错误。 实体“copy”已被引用,但未声明。 我用谷歌搜索了一下,发现我需要修改 escapeMode 。但我不知道我应该在哪里改变
我在有界任务流中有一个 jspx 页面,其中包含从 ViewObject 查询的数据。我想在弹出窗口中以不同的方式呈现相同的数据。我不想想在任务流中使用对话框框架。 我已经在支持 bean 中的 af
我有一个楼层号输入框,我想禁用其中的第一个字符。所以我使用这个 javascript: // 40)) || ($(this).get(0).selectionStart =
我目前正在尝试在 WebLogic 应用服务器上部署一些 RSS 提要。提要的 View 是 .jspx 文件,如下所示: [...]
我想使用 Spring 和 .jspx 网页创建一个 Web 应用程序。 我的问题是如何在 jspx 中放置 IE 的条件注释?它们似乎没有被解释。 此外,我希望我的网页符合
15年前,当我尝试切换到基于XML的JSP时,这是一个问题,看起来仍然是一个问题。 使用Tomcat 9,如果我有一个简单的JSP页面,则可以很好地格式化输出。 Example
在HTML表单中,可以通过在按钮上定义“ disabled”属性(具有任何值)来禁用按钮: Hello 如果要启用按钮,则该属性不应存在,因为没有定义的值可以设置为Disabled属性,否则将使按钮处
我正在 jspx 中迈出第一步。我真的很喜欢 xml 语法。感觉比 jsp 熟悉得多,它迫使我撤消 jsp 所原谅的肮脏黑客行为。其中一个黑客是这样的: " alt="some text" title
这个将在 JSPX 中以某种方式被翻译成 .我让它工作的方法是在里面添加空注释,比如 .我不明白为什么会这样,是否有更好的方法来解决这个问题? 最佳答案 那是 JSP specification
请帮帮我!我在任何 jspx-pages 中多次创建此代码 ${message.message} 我可以创建一次标签并将其包含到我的页面中,就像(例如)在 Ra
在一些关于.jspx的教程中我看到的页面结构如下: NewBook ...但我不明白如何让jspx知道什么是意思是。 那么,如何声明呢? 最佳答案 不能 100% 确
我想在我的 JSPX 中从一些 JSON(通过 Jackson 生成)初始化一个 Javascript 变量,如下所示: var x = ; 但是我得到的输出是这样的: var x = {
我正在定义一个名为“version.tagx”的 tagx 文件。此标记的职责是发出一个 anchor 标记,其显示文本是应用程序的版本号。目前,该文件的定义如下所示:
我有一个在本地开发应用引擎上运行良好的小应用程序,但应用引擎本身不处理我的 .jspx 文件。 jspx 文件位于 WEB-INF 中,因此它们不应被应用引擎排除(作为静态资源) 我正在使用 Apac
使用 JSPX 有条件地打印 html 属性的正确方法是什么? 这些都会在 p 标签上抛出验证错误: /* first try */ hello /* second one */
我们有几个具有可为空字段的域对象。我们已经读到 hibernate 需要“原始”对象才能正确映射它,所以我们的 getter 返回可选值。我们的域对象如下所示: public class User {
.war 由 GlassFish v3 提供。我正在尝试从我的 jspx 中包含一个 javascript 文件。 我在我的 http 响应中得到以下信息 问题是它应该包括 标签。我相信这就是为什
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 9 年前。 Improv
我正在读一本书,作者使用jspx页面。他没有使用 jsp:root 标记作为根标记,而是使用具有与 jsp:root 标记相同的 namespace 声明的 div 标记。这是一个例子:
我想观看网页中的更改,但我不知道如何获取 URL 以将其添加到观察器。 这就是您到达所需页面的方式。首先你去这个page . (如果您遇到服务暂时不可用错误,请尝试强制重新加载,Shift+单击重新加
我是一名优秀的程序员,十分优秀!