java - Eclipse 在 JSP 文件中错误地格式化字符串

标签 java eclipse jsp string-formatting

每当我在 Eclipse Mars 中使用快捷方式 Alt + Control + F 时,它都会弄乱我的字符串“../css/stylesheet.css” < em>jsp 文件。

只有在 <% %> 标签中写入字符串时才会发生。

我查看了 Java -> Code Style -> FormatterHTML Files -> Editor 部分,但找不到解决方案。

输入:

<style type="text/css">
<%@include file="../css/stylesheet.css" %>
</style>

输出:

<style type="text/css">
<%@
include

file
="../css/stylesheet
.css
"

%>
</style>

最佳答案

在标题中你说JSP文件,但在第一行你说css-file,我会展示这两种解决方案,但是如果你有混合HTMLCSS在同一个文件中,需要修改的选项是HTML files

步骤:

  • 菜单:窗口 > 首选项

  • 内部首选项:
    Web > HTML 文件> Editor
    Web > CSS 文件> 编辑器

  • 线宽更改为您喜欢的大小。 enter image description here

  • Alt + Control + F 以获得所需的重新格式化 ;)

输出之后/之前: enter image description here

关于java - Eclipse 在 JSP 文件中错误地格式化字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32054717/

相关文章:

java - 保留原修改时间戳,同时将新文件替换到jar文件中

java - 使用 dom4j 从流中读取单个 XML 文档

java - 如何在 Eclipse Galileo 中创建 Struts 2 项目?

java.lang.RuntimeException : Unable to instantiate activity ComponentInfo java build path

java - 防止JSP页面中输入空值

javascript - HTML 缩放重叠

javascript - 如果在 spring mvc 表单中触发提交按钮的点击函数会发生什么

java - 为什么我得到 Class not found 异常

java - 无法在java中找到while循环行为

java - 无法解析导入 javax.servlet 和 org.hibernate - Ubuntu 12.04 上的 Eclipse Kepler