首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

求帮助,该如何解决

2012-02-22 
求帮助public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletExc

求帮助
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
response.setContentType("text/html");

if(request.getParameter("path")!=null && !"".equals(request.getParameter("path"))){
PrintWriter out = response.getWriter();
out.print(1123123131);
try{ 
  File f = new File(request.getParameter("path"));
  BufferedReader bufRead = new BufferedReader(new InputStreamReader(new FileInputStream(f))); 
  String str; 
  StringBuffer newstr = new StringBuffer("");
   
  while((str = bufRead.readLine()) != null){ 
  newstr.append(str+"<br>");
 
  }
   
   
  if(str!=null && str.length()>0)
  {
  Pattern p = Pattern.compile("<title>(.*?)</title>");

  Matcher m = p.matcher(str);
  while(m.find()){
  System.out.println(m.group(1));
 
  } 
  }
   
   
  request.setAttribute("content", newstr);
   
  }catch(IOException ioe) {ioe.printStackTrace();}
  getServletConfig().getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
}else{
response.sendRedirect("/servlet/index.jsp");
}

}



这个我写的JAVA类 

我假如要+入一些正则表达式去截取 文档的标题 和正文 该怎么+和怎么写

[解决办法]

探讨

关键字 java 正则

[解决办法]
正则比较重要建议楼主认真学学 随便找个教程就可以了
不能老是问别人啊 求人不如求己

热点排行