背景:
我有一个servlet,我在其中动态生成javascript,并将其放入变量<code>脚本text/javascript,并将脚本发送到客户端:
resp.setContentType("text/javascript");
resp.getWriter().println(script);
问题:
浏览器确实下载了javascript文件,但无法识别文件中的函数。如果我创建一个静态javascript文件并使用它,它会很好地工作。
问题:
应该做些什么才能使浏览器将servlet的响应视为常规的javascript文件?
谢谢你的帮助。