Java learning JSP

Java learning JSP

0x00 Preface

In fact, there is not much about JSP. Let's simply record the conceptual content of JSP to avoid forgetting.

0x01 JSP concept

The full name of JSP is Java Server Pages: Java server-side pages.

In fact, JSP is essentially a servlet. When JSP is parsed, the middleware will automatically convert it into a servlet Java suffix file. And Java files will be converted into bytecode files by middleware, so that they can be parsed and run.

0x02 written by JSP

Definition format of jsp:

1. <%  代码 %>:定义的java代码,在service方法中。service方法中可以定义什么,该脚本中就可以定义什么。

2. <%! 代码 %>:定义的java代码,在jsp转换后的java类的成员位置。

3. <%= 代码 %>:定义的java代码,会输出到页面上。输出语句中可以定义什么,该脚本中就可以定义什么。


<%@ 指令名称 属性名1=属性值1 属性名2=属性值2 ... %>

JSP Directive:

1. page		: 配置JSP页面的
			* contentType:等同于response.setContentType()
				1. 设置响应体的mime类型以及字符集
				2. 设置当前jsp页面的编码(只能是高级的IDE才能生效,如果使用低级工具,则需要设置pageEncoding属性设置当前页面的字符集)
			* import:导包
			* errorPage:当前页面发生异常后,会自动跳转到指定的错误页面
			* isErrorPage:标识当前也是是否是错误页面。
				* true:是,可以使用内置对象exception
				* false:否。默认值。不可以使用内置对象exception

2. include	: 页面包含的。导入页面的资源文件
			* <%@include file="top.jsp"%>
3. taglib	: 导入资源
			* <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
				* prefix:前缀,自定义的

0x03 end

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>