题外话:如果用EditPlus作为编辑器的话如果保存的格式默认为unicode的话那么在里面写中文用resin作为应用服务器的话就可能出现报500 Servlet错误哦!主要是因为编码的问题!
所以要注意好页面的编码问题!有时间我得作一个专题专门来讨论一下有关JSP中编码的问题哦!
题外话二:研究如何读LINUX的服务器IP
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
public class GetIp {
public static void main(String[] args){
String ip = null;
GetIp test = new GetIp();
try{
ip = test.getLocalSiteIP();
}catch(Exception e){
System.out.print(e.toString());
}
System.out.print(ip);
}
private String getLocalSiteIP() throws Exception {
String siteString = "";
Enumeration netInterfaces = NetworkInterface.getNetworkInterfaces();
while (netInterfaces.hasMoreElements()) {
NetworkInterface ni = (NetworkInterface) netInterfaces.nextElement();
InetAddress ip = (InetAddress) ni.getInetAddresses().nextElement();
if (ip.isSiteLocalAddress() && !ip.isLoopbackAddress() &&
ip.getHostAddress().indexOf(":") == -1) {
siteString = ip.getHostAddress();
}
}
return siteString;
}
}
阅读(568) | 评论(0) | 转发(0) |