idea配置JSP模板

1.新建 jsp 文件时的模板

image.png

在第 5 步输入下面模板代码:

<%--
  Created by IntelliJ IDEA.
  User: ${USER}
  Date: ${DATE}
  Time: ${TIME}
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>
<html>
<head>
<base href="<%=basePath %>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Insert title here</title>
</head>
<body>

</body>
</html>

2.快捷键快速生成 jsp 模板


image.png

在第7步填入下面代码:

<%--
  Created by IntelliJ IDEA.
  User: $USER$
  Date: $DATE$
  Time: $TIME$
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>
<html>
<head>
<base href="<%=basePath %>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Insert title here</title>
</head>
<body>

</body>
</html>

第8步编辑变量


image.png

配置完毕

  • 新创建jsp文件
    或者
  • 在已有的jsp文件输入jsp 摁Tab键
    效果如下
<%--
  Created by IntelliJ IDEA.
  User: charay
  Date: 2020/1/18
  Time: 1:47 下午
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>
<html>
<head>
<base href="<%=basePath %>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Insert title here</title>
</head>
<body>

</body>
</html>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 官网 中文版本 好的网站 Content-type: text/htmlBASH Section: User ...
    不排版阅读 4,434评论 0 5
  • Web网站测试流程和方法(转载) 1测试流程与方法 1.1测试流程 进行正式测试之前,应先确定如何开展测试,不可盲...
    夏了夏夏夏天阅读 1,316评论 0 0
  • 一. Java基础部分.................................................
    wy_sure阅读 3,832评论 0 11
  • Ctrl+Shift + Enter,语句完成 “!”,否定完成,输入表达式时按 “!”键 Ctrl+E,最近的文...
    Alex_1799阅读 501评论 0 0
  • 背景 起源是一款刀具LIQUIDIAMOND,号称可以达到HRc70+,目前市面较高端的刀具,一般的日本高端高碳钢...
    转丸阅读 1,136评论 0 0