`
Ydoing
  • 浏览: 101064 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

JSP语法简介

 
阅读更多

JSP指令

<%@ 指令名 属性=”值”>

page指令

<%@ page contentType="text/html; charset=GB2312" %>  

include指令

<%@ include file="banner.jsp" %>  

JSP声明

声明JSP对应Servlet类的成员变量

<%!
private int var = 0;
private String str;
%>

Java程序

<%
    //Get the identifier of the book to display
    String bookId = request.getParameter("bookId");
    if(bookId==null)bookId="201";
    BookDetails book = bookDB.getBookDetails(bookId);
%>
<% 
   if(book==null)
   { 
%>
    <p>书号"<%=bookId%>"在数据库中不存在<p>
    <strong><a href="<%=request.getContextPath()%>/catalog.jsp">继续购物</a></strong>
<% 
     return;
   }
%>  

Java表达式

<p>书名:<%=convert(book.getTitle())%></p> 

隐含对象

  • request(javax.servlet.http.HttpServletRequest)
  • pageContext (javax.servlet.jsp.PageContext)
  • session (javax.servlet.http.HttpSession)
  • application (javax.servlet.ServletContext)
  • config (javax.servlet.ServletConfig)
  • out (javax.servlet.jsp.JspWriter)
  • page(java.lang.Object page)
  • pageContext (javax.servlet.jsp.PageContext)
  • exception(java.lang.Exception)
<script type="text/javascript"> $(function () { $('pre.prettyprint code').each(function () { var lines = $(this).text().split('\n').length; var $numbering = $('<ul/>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('<li/>').text(i)); }; $numbering.fadeIn(1700); }); }); </script>

版权声明:本文为博主原创文章,未经博主允许不得转载。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics