网站开发的业内人士,在哪些网站可以发布推广信息,深圳it培训,软件开发设计文档文章目录java 的注释单行注释多行注释文本注释jsp 的注释第一种第二种第三种css 的注释js 的注释单行注释奇葩的单行注释多行注释文档注释xml 的注释html 的注释java 的注释
单行注释
public class HelloWorld{public static void main(String [] args){System.out.println(HelloWorld);//This is my first java}
}选中你要加注释的区域用 ctrlshiftc 或者 ctrl/ 会加上 // 注释再重复按一下就会去掉 // 注释。
多行注释
/**This*my*first*java*/
public class HelloWorld{public static void main(String [] args){System.out.println(HelloWorld);}
}选中你要加注释的区域用 ctrlshift/ 会加上 /…/ 注释再用 ctrlshift\ 会去掉 /…/ 注释。注意正斜杠是加注释反斜杠是去掉注释
文本注释
/***This*is*my*first*java*/
public class HelloWorld{public static void main(String [] args){System.out.println(HelloWorld);}
}快捷键为AltShiftJ
jsp 的注释
第一种
!-- %new Date()% --注释中的代码会执行只是结果并不会在页面上显示出来而已但是整个注释内容会输出到页面中。
例如
!-- %new Date()% --会执行JSP表达式并且将结果、注释符号一起输出到页面中你查看页面的源码会看到如下的内容
!-- Fri May 27 11:59:37 CST 2022 --这种格式的注释快捷键shiftctrlc 单行注释没有ctrl/快捷键shiftctrl/ 多行注释。
这是 HTML/XML 的原版注释会老老实实的发到客户端的有什么见不得人的就别用这个写了。
第二种
%--注释内容--% 注释中的代码不会执行也不会在页面上输出。 这种格式的注释没有快捷键。 jsp文件没有文本注释你非要说有文本注释那也是写在java代码片段里面或者写在声明片段里面。
有%-- --%的东西都是写给JSP应用服务器看的不会发到客户端的。编译器将其置之不理html也无缘与其相见被应用服务器打入冷宫了。这个注释感觉比较多余不知道专门又搞一个这种注释干什么。
第三种
%
//当行注释
/**
多行注释
*/
%css 的注释
/*这是单行注释*//*这是多行注释这是多行注释这是多行注释
*/js 的注释
单行注释
// 这是一行注释
// 另一行注释奇葩的单行注释
这种单行注释不是很常见会和 html 内的注释混淆不推荐使用。这种注释后面是不要加 --这是和 html 注释不一样的地方。
!- 这是一行注释(#^.^#)多行注释
一般写在 js 文件的开头位置或者写在声明函数的前面用来介绍作者、参数、函数用途等信息
/** Author:liaowenxiong* Date:2008-08-10*/文档注释
类似于 Java 的文档注释
/*** Maps children that are typically specified as props.children.** See https://reactjs.org/docs/react-api.html#react.children.map** The provided mapFunction(child, key, index) will be called for each* leaf child.** param {?*} children Children tree container.* param {function(*, int)} func The map function.* param {*} context Context for mapFunction.* return {object} Object containing the ordered map of results.*/
function mapChildren(children, func, context) {if (children null) {return children;}var result [];mapIntoWithKeyPrefixInternal(children, result, null, func, context);return result;
}参数变量名与参数说明之间使用连字符 -会使阅读更友好
/*** param {object} partialState - Next partial state to be merged with state.*/大括号内的object 表示参数的类型说明该参数是一个对象partialState 是参数名称Next partial state to be merged with state. 这是参数的说明信息。
描述一个对象参数的属性
/*** param {Object} employee - The employee who is responsible for the project.* param {string} employee.name - The name of the employee.* param {string} employee.department - The employees department.*/假如 employee 参数是一个对象数组这个数组中的元素对象包含 name 和 department 属性那么可以这么描述
/*** Assign the project to a list of employees.* param {Object[]} employees - The employees who are responsible for the project.* param {string} employees[].name - The name of an employee.* param {string} employees[].department - The employees department.*/JS 的注释建议详见《JavaScript代码注释范例》
xml 的注释
单行注释使用shiftctrlc进行注释再次使用取消注释没有ctrl/快捷键 多行注释使用shiftctrl/进行注释使用shiftctrl\取消注释。 没有文本注释。
xml 注释
error-page
!--方式1 --
error-code500/error-code
!--方式2
exception-typejavax.servlet.ServletException /exception-type
--
location/error.html/location
/error-pagehtml 的注释
其实和 xml 的注释一样。
!--这是单行注释--
!--这是多行注释这是多行注释这是多行注释
--