- 论坛徽章:
- 0
|
1. 换皮肤问题
换肤问题,“内容与表现相分离”。一套内容,多套表现。xml文档提供内容,该怎么样显示,由css或xsl定义。以后尽量采用 DIV + CSS 模式。
一个简单的换皮肤例子:
换肤
function chickSkin(name) {
document.getElementById("skin").href=name;
return false;
}
aaaaaa
bbbbbb
cccccc
红色
绿色
Css 代码如下:
red.css
.info {
color:red;
txt-decoration="none";
}
green.css
.info {
color:green;
}
CSS中可以用 txt-decoration="none";去掉超连接的下划线。
小知识:
更改浏览器打开时的编码为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 FileInputStream(f);
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);
}
}
}
标签:
Java培训
广州软件培训
编程培训
程序员培训
广州JAVA培训
JAVA培训班
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/97775/showart_1949664.html |
|