SQL SERVER 2008 和SQLSERVER2008,前者形式在下面代碼中運行會出錯,後者不報500,這是什麼原因?求大神指點
Books.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<a href="book.jsp?book=JavaWeb">JavaWeb</a><br><br>
<a href="book.jsp?book=JSP">JSP</a><br><br>
<a href="book.jsp?book=html5">html5</a><br><br>
<a href="book.jsp?book=SQLSERVER2008">SQLSERVER2008</a><br><br>
<a href="book.jsp?book=Struts2">Struts2</a><br><br>
<a href="book.jsp?book=Spring">Spring</a><br><br>
<a href="book.jsp?book=Oracle">Oracle</a><br><br>
<a href="book.jsp?book=XML">XML</a><br><br>
<a href="book.jsp?book=HTML">HTML</a><br><br>
<a href="book.jsp?book=JavaScript">JavaScript</a><br><br>
<br><br>
<%
//顯示最近浏覽的五本書
//獲取所有的cookie
Cookie[] cookies = request.getCookies();
//從中篩選出book的cookie,如果cookieName為ATGUIGU_BOOK_開頭即符合條件
//顯示CookieValue
if(cookies != null && cookies.length > 0){
for(Cookie c:cookies){
String cookieName = c.getName();
if(cookieName.startsWith("ATGUIGU_BOOK_")){
out.println(c.getValue());
out.println("<br>");
}
}
}
%>
Book.jsp
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<h4>Book Detail Page</h4>
Book:<%=request.getParameter("book") %>
<br><br>
<a href="books.jsp">return</a>
<%
String book = request.getParameter("book");
//把書的信息以cookie的方式傳回給浏覽器,刪除一個cookie
//1.確定要被刪除的一個cookie
//前提:ATGUIGU_BOOK_開頭的cookie數量大於或等於5,
Cookie[] cookies = request.getCookies();
//用來保存所有以ATGUIGU_BOOK_開頭的BOOK的cookie信息
List<Cookie> bookCookies = new ArrayList<Cookie>();
//用來保存和books.jsp傳入的book匹配的那個cookie
Cookie tempCookie = null;
if(cookies != null && cookies.length > 0){
for(Cookie c:cookies){
String cookieName = c.getName();
if(cookieName.startsWith("ATGUIGU_BOOK_")){
bookCookies.add(c);
if(c.getValue().equals(book)){
tempCookie = c;
}
}
}
}
//(1)且若從books.jsp頁面傳入的book不在ATGUIGU_BOOK_的cookie中則刪除較早的那個cookie
//(ATGUIGU_BOOK_數組的第一個cookie)
if(bookCookies.size() > 5 && tempCookie == null){
tempCookie = bookCookies.get(0);
}
//(2)若在其中則刪除該cookie
if(tempCookie != null){
tempCookie.setMaxAge(0);
response.addCookie(tempCookie);
}
//2.把從books.jsp頁面傳入的book作為一個cookie返回
Cookie cookie = new Cookie("ATGUIGU_BOOK_" + book,book);
response.addCookie(cookie);
%>
SQLSERVER2008是作為一個參數存在的,SQL SERVER 2008,編譯器檢查時不能作為參數存在,“SQL SERVER 2008”此時字符串