这个问题困扰好几天了。
servlet doget方法:
protected void doGet(HttpServletRequest req, HttpServletResponse resp) { 
resp.setContentType("text/html"); 
ContentHtml contenHtml = new HtmlCreater.InitHtmlContent();
PrintWriter w = resp.getWriter(); 
w.println(contentHtml.getHtmlpage()); //输出a.html页面 
}a.html 部分:
<script src="/abc/js/jquery/jquery.1.11.1.min.js"></script> 
<script src="/abc/js/jquery/jquery.serialize-object.min.js"></script>
<link rel="stylesheet" href="/abc/css/bootstrap/bootstrap-theme.min.css">容器为 tomcat, 项目名为abc;
单独输出a.html 页面没有任何问题;
但通过 servlet 输出a.html 时,页面中引入的 js,css文件全都不能识别(js 文件内容没有问题),都指向了a.html页面.
运行时报如下错误:Uncaught SyntaxError: Unexpected token < jquery.serialize-object.min.js:1 
Uncaught SyntaxError: Unexpected token < jquery.1.11.1.min.js:1Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:8080/abc/css/bootstrap/bootstrap.min.css".

解决方案 »

  1.   

    Uncaught SyntaxError: Unexpected token < jquery.serialize-object.min.js:1 
    F12 看下js的路径是否正确。Resource interpreted as Stylesheet but transferred with MIME ty ...
    看下web.xml中 filter的配置。
      

  2.   

    不用回复了。问题原因是,web.xml里面配置的servlet选项有问题,导致页面中的静态资源都被过滤掉了。关于怎么处理这个问题,网上已经有很多答案了。
      

  3.   

    加绝对路径吧   ${pageContext.request.contextPath}/