Java for Web学习笔记(十六):JSP(6)jspx
2016-02-14 10:45
746 查看
JSP document的后缀名是.jspx,它采用XML格式,因此表述方式完全不同:
下面是一个简单JSP document的例子,最基本的差异就是书写的格式不同。
相关链接:
我的Professional Java for Web Applications相关文章
| JSP语法 | JSP document语法 |
Page Directive | <%@ page %> | <jsp:directive.page /> |
Include Directive | <%@ include %> | <jsp:directive.include /> |
Tag Library Directive | <%@ taglib %> | xmlns:prefix=”Library URI” |
Declartion | <%! … %> | <jsp:declaration> … </jsp:declaration> |
Scriplet | <% … %> | <jsp:scriptlet> … </jsp:scriptlet> |
Expression | <%= … %> | <jsp:expression> … </jsp:expression> |
Comment | <%-- … --%> | <!-- … --> |
<?xml version="1.0" encoding="UTF-8"?> <jsp:root xmlns="http://www.w3.org/1999/xhtml" version="2.0" xmlns:jsp=http://java.sun.com/JSP/Page xmlns:c="http://java.sun.com/jsp/jstl/core"> <jsp:directive.page contentType="text/html;charset=UTF-8" language="java" /> <jsp:directive.include file="/WEB-INF/jsp/base.jspx" /> <jsp:declaration> private static final String DEFAULT_USER = "Guest"; </jsp:declaration> <jsp:scriptlet> String user = request.getParameter("user"); if(user == null) user = DEFAULT_USER; </jsp:scriptlet> <!-- <jsp:expression>"This code is commented"</jsp:expression> --> <!DOCTYPE html> <html> <head> <title>Hello User Application</title> </head> <body> Hello, <jsp:expression>user</jsp:expression>!<br /><br /> <form action="greeting.jsp" method="post"> Enter your name:<br /> <input type="text" name="user" /><br /> <input type="submit" value="Submit" /> </form> </body> </html> </jsp:root>
相关链接:
我的Professional Java for Web Applications相关文章
相关文章推荐
- java getResourceAsStream
- 个人学习-java-关键字super
- java定时任务的实现方式
- jdk下载地址
- JAVA Hibernate工作原理及为什么要用
- spring与mybatis三种整合方法
- 《java设计模式》之观察者模式
- Spring Batch入门实例教程实现对CVS文件的操作
- 简单讲解Java设计模式编程中的单一职责原则
- JVM参数详解
- Cannot open Eclipse Marketplace
- Java Web项目发布及使用自定义域名
- A Java RunTime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Ecl
- eclipse 一些插件地址
- abstract class和interface的使用场景分别是什么?
- JAVA安装——Windows
- SpringBoot项目推荐-Gradle版本
- Windows下的NetBeans安装及配置
- 整理Java编程中常用的基本描述符与运算符
- Java eclipselink eclipselink.ddl-generation 的四种方式