熟悉了下JSP裏面的Java代碼

概述:基礎知識還是比較薄弱啊,今天在做項目都有點不記得了,還是寫下來以防萬一吧

<%@ page import="java.io.IOException" %>

<%--

  Created by IntelliJ IDEA.

  User: Administrator

  Date: 15-1-19

  Time: 上午11:31

  To change this template use File | Settings | File Templates.

--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%

    String header = (String)request.getAttribute("mpHeader");

    String id = (String)request.getAttribute("id");

    if(header.indexOf("MicroMessenger")==-1){//判斷是否是微信瀏覽器

        try {

            response.sendRedirect("mp_ajax_vcf.html?id="+id);//如果是就異步跳轉,如果不是就執行接下去

        } catch (IOException e) {

            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.

        }

    }

%>

<html>

<head>

    <title>通訊錄</title>

<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">

</head>

<body style="background:url(<%=request.getContextPath()%>/p_w_picpaths/weixintype.jpg) top right no-repeat rgba(0,0,0,.8);background-size: 290px;" >

//<%=request.getContextPath()%>獲取項目根目錄

</body>

</html>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章