15

我想配置 eclipse 以便:

我的原始代码格式:

name: <input type="text" value="${event.name}" name="name" /> <br /> description: <input type="text" value="${event.description}"   name="description" /> <br />eventDate:<input    type="date" value="${event.eventDate}" name="resumeUrl" /><br />

我的目标代码格式:

 name: <input type="text" value="${event.name}" name="name" /> 
 <br /> 
  description: 
 <input type="text" value="${event.description}"    name="description" /> 
 <br />
  eventDate:
 <input type="date" value="${event.eventDate}" name="resumeUrl" />
 <br />

我想得到1 line = 1 tag

如何配置 eclipse 以将我的原始格式重新格式化为目标格式?

4

5 回答 5

23

在日食中:

  • 对于 Windows 打开窗口菜单 -> 选择首选项
  • 对于 Mac 打开 EclipceMenu -> 选择首选项

从首选项窗口中选择 Web => HTML Files => Editor

Inline Elements:视图中,添加您希望在一行中显示的所有标签

现在,每当您按CTRL+ SHIFT+F时,JSP 都会被格式化为您的新样式

于 2013-09-03T12:51:44.167 回答
2

也许你可以试试这个:Window -> Preference -> Web -> HTML Files ->Editor -> Formatting :将“Line width”更改为 200 或更大

于 2018-01-18T07:55:52.333 回答
0

从 Eclipse 窗口菜单中,选择首选项

从首选项窗口中选择 Web => HTML Files => Editor

增加线宽并使用ctrl+shift+F.

于 2014-05-28T06:42:07.867 回答
0

您可以CTL+SHIFT+F在 eclipse 中使用,但请确保您已在 jsp 编辑器中打开 jsp。

如果没有,请转到 Eclipse - 窗口 - 首选项 - 常规 - 编辑器 - 文件关联

并选择文件类型为 *.jsp 并将 JSP 编辑器设置为默认值

于 2013-09-03T12:51:31.307 回答
-2

不,您不能简单地使用 ctrl+shift+f 格式化 jsp(html & jsp scriplets) 页面,如果您使用该键,它将使您的代码更改语法,例如:

{
    String error = request.getAttribute("error") != null ? (String) request.getAttribute("error"): "";%>
} 

此代码将其更改为

{
    String error = request.getAttribute("error") != null ? (String) request.getAttribute("error") : "";%> 
}, 

再次使用键后,您必须手动对齐此脚本

于 2014-11-25T09:32:28.257 回答