我是靠谱客的博主 温暖书包,最近开发中收集的这篇文章主要介绍vscode 模板代码块配置 Servlet为例,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

 设置 =》 配置用户代码片段 =》 新建全局代码片段文件

{
  // Place your 全局 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
  // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
  // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
  // used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
  // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
  // Placeholders with the same ids are connected.
  // Example:
  // "Print to console": {
  // 	"scope": "javascript,typescript",
  // 	"prefix": "log",
  // 	"body": [
  // 		"console.log('$1');",
  // 		"$2"
  // 	],
  // 	"description": "Log output to console"
  // }
  "Print to console": {
    // 代码块的作用文件类型
    "scope": "java",
    // 触发代码块的字符串。
    "prefix": "serv_",
    // $1使用代码块敲击回车或者tab键后光标定位的位置。 
    //$2 $3 $4...表示我们按下tab光标依次出现的位置
    "body": [
      "import javax.servlet.ServletException;",
      "import javax.servlet.http.HttpServlet;",
      "import javax.servlet.http.HttpServletRequest;",
      "import javax.servlet.http.HttpServletResponse;",
      "import java.io.IOException;",
      "import javax.servlet.annotation.WebServlet;",

      "@WebServlet("$2")",
      "public class $1 extends HttpServlet{",
      "@Override",
      "protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {",
      "$3",
      "}",

      "@Override",
      "protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {",
      "this.doGet(request,response);",
      "$4",
      "}",
      "}"
    ],
    //描述
    "description": "servletmodel"
  }
}

最后

以上就是温暖书包为你收集整理的vscode 模板代码块配置 Servlet为例的全部内容,希望文章能够帮你解决vscode 模板代码块配置 Servlet为例所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(45)

评论列表共有 0 条评论

立即
投稿
返回
顶部