为啥我引入的jquery库要被拦截

braveboyny 2019-05-16 11:38:57
这是web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">

<servlet>
<servlet-name>mysevlet</servlet-name>
<servlet-class>org.neolyao.servlet.MyServlet</servlet-class>
</servlet>

<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="/js/jquery.min.js"></script>

<title>Ajax page</title>
<script type="text/javascript">
$("document").ready(function(){
$("#btn").click(function(){
$.ajax({
type:"GET",
url:"/chart.do?chatMsg=hello",
success:function(data){
$("#get").val(data);
}
})
});
});

</script>
</head>
<body>

接收:<input type="text" id="get" /><br>
<button id="btn">发送</button>

</body>
</html>


...全文
254 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
那年花 2019-05-21
  • 打赏
  • 举报
回复
你是路径不对吧
别闹腰不好 2019-05-16
  • 打赏
  • 举报
回复
404 不是拦截
braveboyny 2019-05-16
  • 打赏
  • 举报
回复
引用 1 楼 Gemini_Kanon 的回复:
配置静态资源映射了吗
<servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.js</url-pattern> </servlet-mapping> 这么配置了还不行吗,我没用springmvc ,只用servlet要怎么配置呢
Gemini_Kanon 2019-05-16
  • 打赏
  • 举报
回复
配置静态资源映射了吗

81,095

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧