Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java EE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:JAVA学习日子分享 [Re:fhdking]
fhdking





发贴: 28
积分: 0
于 2007-10-21 14:53 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
1. 换皮肤问题
换肤问题,“内容与表现相分离”。一套内容,多套表现。xml文档提供内容,该怎么样显示,由css或xsl定义。以后尽量采用 DIV + CSS 模式。
一个简单的换皮肤例子:
<HTML>
  <HEAD>
    <META HTTP-EQUIT="Content-Type" content="text/html,charset=GBK" />
    <LINK rel="stylesheet" href="red.css" type="text/css" id="skin" />
    <title>换肤</title>
    <script>
      function chickSkin(name) {
        document.getElementById("skin").href=name;
        return false;
      }
    </script>
  </HEAD>
  <body>
    <span class="info">aaaaaa</span><br>
    <span class="info">bbbbbb</span><br>
    <span class="info">cccccc</span><br>
    <a href="#" onclick="return chickSkin('red.css')">红色</a>
    <a href="#" onclick="return chickSkin('green.css')">绿色</a>
  </body>
</HTML>
Css 代码如下:
red.css
.info {
  color:red;
  txt-decoration="none";
}
green.css
.info {
  color:green;
}
CSS中可以用 txt-decoration="none";去掉超连接的下划线。
小知识:
更改浏览器打开时的编码为GBK可以在<head></head>标签对内加入:<meta http-equiv="Content-Type" content="text/html;charset=GBK">
2. 浏览器与web服务器互交的过程
讲述了浏览器与web服务器互交的过程,分析程序:
import java.net.*;
import java.io.*;
public class HttpServer
{
  public static void main(String [] args) throws Exception
  {
    ServerSocket serverSocket = new ServerSocket(Integer.parseInt(args[0]));
    while(true)
    {
      Socket socket = serverSocket.accept();
      new Thread(new Server(socket)).start();
    }
  }  
}  
class Server implements Runnable
{
      Socket s = null;
      public Server(Socket s)
      {
        this.s = s;
      }
      public void run()
      {
        try
        {
          InputStream ips = s.getInputStream();
          BufferedReader br = new BufferedReader(new InputStreamReader(ips));
          String line = br.readLine();
          //GET /a.html HTTP/1.1
          String firstLine = line;
          while(/*(line == null) || */!"".equals(line))
          {
            System.out.println(line);
            line = br.readLine();
          }
          String parts [] = firstLine.split(" +");
          /*StringTokenizer st = new StringTokenizer(firstLine);
          while(st.hasMoreToken())
          {
            st.nextToken();
          }*/
          System.out.println(parts[1]);
          File f = new File("d:\\webcontent",parts[1].substring(1));
          FileInputStream fis = new FileInputStreamRose;
          OutputStream ops = s.getOutputStream();
          copyStream(fis,ops);
          br.close();
          ops.close();
          fis.close();
          s.close();
        }catch(Exception e){e.printStackTrace();}
      }
      void copyStream(InputStream fis,OutputStream ops) throws Exception
      {
          byte [] buf = new byte[1024];
          int len = 0;
          while((len=fis.read(buf)) != -1)
          {
            ops.write(buf,0,len);
          }
      }
}




话题树型展开
人气 标题 作者 字数 发贴时间
100135 JAVA学习日子分享 fhdking 3647 2007-10-16 16:03
97145 Re:JAVA学习日子分享 fhdking 1568 2007-10-17 13:51
95055 Re:JAVA学习日子分享 fhdking 18 2007-10-25 14:21
95488 Re:JAVA学习日子分享 fhdking 3449 2007-10-25 14:27
95488 Re:JAVA学习日子分享 fhdking 1407 2007-10-26 14:21
95029 Re:JAVA学习日子分享 fhdking 59 2007-10-28 14:17
94994 Re:JAVA学习日子分享 fhdking 1380 2007-10-28 14:21
94982 Re:JAVA学习日子分享 fhdking 841 2007-10-29 14:29
95205 Re:JAVA学习日子分享 fhdking 2640 2007-10-30 13:25
94661 Re:JAVA学习日子分享 wwww6662003 8 2007-11-01 07:47
94831 Re:JAVA学习日子分享 fhdking 72 2007-11-04 13:53
95820 Re:JAVA学习日子分享 fhdking 2678 2007-11-04 13:56
95720 Re:JAVA学习日子分享 fhdking 2274 2007-10-18 14:07
94814 Re:JAVA学习日子分享 fhdking 903 2007-11-05 15:15
95507 缓存问题 fhdking 3108 2007-11-07 15:49
95155 Re:JAVA学习日子分享--路径问题 fhdking 3766 2007-11-07 15:53
94266 Re:JAVA学习日子分享--路径问题 JJ_JJ 57 2007-11-09 01:23
97637 JSP乱码和out内置对象 fhdking 3357 2007-11-08 09:33
94412 Re:JAVA学习日子分享 fhdking 73 2007-11-09 17:57
97119 include和forward方法 fhdking 3648 2007-11-12 10:21
94205 Re:JAVA学习日子分享 王勇 19 2007-11-17 18:05
93914 Re:JAVA学习日子分享 fhdking 46 2007-11-19 15:06
94442 Re:JAVA学习日子分享 fhdking 9819 2007-11-19 15:17
94336 Re:JAVA学习日子分享 fhdking 6200 2007-11-20 11:05
95688 Re:JAVA学习日子分享 fhdking 1623 2007-10-19 13:33
95885 培训日记(利用session自动登录) fhdking 6190 2007-11-21 11:05
92938 Re:JAVA学习日子分享 ws5696611 54 2007-12-26 19:09
93535 Re:JAVA学习日子分享 g007 10 2008-01-14 15:26
95217 Re:JAVA学习日子分享 fhdking 2579 2007-10-21 14:53
95181 Re:JAVA学习日子分享 fhdking 313 2007-10-22 15:46
95501 Re:JAVA学习日子分享 fhdking 1733 2007-10-23 13:42
95281 Re:JAVA学习日子分享 fhdking 1929 2007-10-24 13:37
94834 Re:JAVA学习日子分享 yunshao110 5 2007-10-25 07:51
95012 Re:JAVA学习日子分享 yunshao110 5 2007-10-25 07:54

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923