Tomcat无法访问到本地指定的html
http://localhost:8080/ 访问会弹出Tomcat7.0.63的页面。
但是我输入http://localhost:8080/myweb/110.html,就挂了。
HTTP Status 404 - /myweb/110.html
type Status report
message /myweb/110.html
description The requested resource is not available.
在tomcat下面确实有myweb文件,110.html也在里面,为什么访问不到呢?
另外这个代码编译没错误,但是运行的时候也报异常了。
代码:
import java.io.*;
import java.util.regex.*;
import java.net.*;
import java.util.*;
class RegexTest2
{
public static void main(String[] args) throws Exception
{
getMails_1();
}
public static void getMails_1()throws Exception
{
URL url = new URL("http://localhost:8080/myweb/110.html");
URLConnection conn = url.openConnection();
BufferedReader bufIn = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line = null;
String mailreg = "\\w+@\\w+(\\.\\w+)+";
Pattern p = Pattern.compile(mailreg);
while((line=bufIn.readLine())!=null)
{
Matcher m = p.matcher(line);
while(m.find())
{
System.out.println(m.group());
}
}
}
}
异常信息:
Exception in thread "main" java.io.FileNotFoundException: http://localhost:8080/
myweb/110.html
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLCo
nnection.java:1835)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:1440)
at RegexTest2.getMails_1(RegexTest2.java:22)
at RegexTest2.main(RegexTest2.java:12)