码迷,mamicode.com
首页 > Web开发 > 详细

Web(一)

时间:2017-06-18 12:01:17      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:lan   style   tar   sep   分享   项目   key   strong   index   

Tomcat 服务器       B/S 浏览器/服务器       C/S 客户端/服务器
技术分享
 URI :大 广 /项目名                      URL: 小  http://localhost:8080/项目名/页面
技术分享
 
技术分享
 
技术分享
 
技术分享
 
技术分享
 JSP的生命周期
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP ‘index.jsp‘ starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
    <%!//全局变量
    int initNum = 0;
    int serviceNum = 0;
    int destroyNum = 0;
    %>
    <%!//书写两个方法
    public void jspInit() {
        initNum++;
        System.out.println("jspInit()初始化执行了" + initNum + "次");
    }
    public void jspDestroy() {
        destroyNum++;
        System.out.println("jspdestroy()销毁执行了" + destroyNum + "次");
    }
    %>
    <%
        //只要是没有! 所有的内容都会在service中
        //service()
        serviceNum++;
        System.out.println("jspDestroy()销毁执行了" + destroyNum + "次");
        String sayInit = "初始化次数" + initNum;
        String sayService = "执行次数" + serviceNum;
        String sayDestroy = "销毁次数" + destroyNum;
    %>
    <%=sayInit%><br/>
    <%=sayService%><br/>
    <%=sayDestroy%><br/>
</body>
</html>
技术分享
 
技术分享
 
技术分享
 
技术分享
 
技术分享
 
技术分享
 

Web(一)

标签:lan   style   tar   sep   分享   项目   key   strong   index   

原文地址:http://www.cnblogs.com/HHR-SUN/p/7043508.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!