开发者社区> 问答> 正文

java读取本地的html文件并且将其样式原样的显示在浏览器中

java读取本地html文件并且将其样式原样的显示在浏览器中,且不能将其路径显示在地址栏中!求大神解答!就这些币了,全给了!

展开
收起
小旋风柴进 2016-03-12 10:49:46 5947 0
1 条回答
写回答
取消 提交回答
  • 类似这样

    
    public class ServletClass extends HttpServlet
    {
    protected void doGet(HttpServletRequest request , HttpServletResponse response)
    {
      this.doPost(request , response);
    }
    
    protected void doPost(HttpServletRequest request , HttpServletResponse response)
    {
      int i = 1;
    
      try {
       request.setCharacterEncoding("utf-8");
       response.setContentType("text/html;charset=utf-8");
       PrintWriter out = response.getWriter();
    
       out.println("<html>");
       out.println("<head>");
       out.println("<title></title>");
       out.println(" <meta http-equiv='keywords' content='keyword1,keyword2,keyword3'>");
       out.println("<meta http-equiv='description' content='this is my page'>");
       out.println("<meta http-equiv='content-type' content='text/html; charset=UTF-8'>");
       out.println("<link rel='stylesheet' type='text/css' href='css/index.css'>");
       out.println(" </head>");
       out.println("<body >");
    
    
       out.println("</div>");
       out.println(" </body>");
       out.println("</html>");    
    
      } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      }
    }
    }
    2019-07-17 19:00:25
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
基于浏览器的实时构建探索之路 立即下载
天猫HTML5互动技术实践 立即下载
基于浏览器的实时构建探索之路--玄寂 立即下载