这个问题困扰好几天了。
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".
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".
解决方案 »
- java系统和.net系统实现单点登录问题?求教大侠指点!
- Error creating bean with name 'sessionFactory' defined in class path resource
- struts2的问题(头疼)
- java I/O问题
- 用户登录的时候,在短时间内密码连续输错3次,账号被锁定,是怎么实现的呢?
- spring的两个菜鸟级问题
- 偶想 将取出的时间2005-05-27 10:45:46变成 2005-05-27 用什么方法可以实现?
- 谁有md5方面加密的东东吗?
- 关于httpservletlistener的问题(急!)
- 怎么样才能实现刷新?给分!!!!
- 求java实现多车辆、多地点配送路径规划问题(VRP)
- 模仿网上的easyui做了个系统,请问还有其他类似的easyui模板包让我直接替换的吗?
F12 看下js的路径是否正确。Resource interpreted as Stylesheet but transferred with MIME ty ...
看下web.xml中 filter的配置。