我是JSP,外部的jquery文件在春季MVC中不工作?
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%-- <%@include file="include.jsp"%> --%>
<%@ taglib prefix="form" uri="../tld/spring-form.tld" %>
<!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">
<title>Insert title here</title>
<script type="text/javascript" src="/jquery/jquery-1.9.1.js"></script>
<script type="text/javascript" src="/jquery/hello.js"></script>
</head>
<body>
<%out.println("Hello") ;%>
<form:form commandName="person">
Select A or B :
<form:input path="option" id="option" />
<input type="button" value="Ajax Submit" onclick="hello();">
<p id = "result"></p>
</form:form>
</body>
</html>
out.println("Hello")
打印在瀏覽器和形式也displayed.Only外部jQuery是沒有工作做的JavaScript調用。
我的調度員的Servlet會,
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
我的外部hello.js包含,
function hello(){
alert("Hello 99");
var val = $("#option").val();
alert("Option : "+val);
}
我的項目結構,
當我點擊按鈕我在控制檯
中得到這個Apr 8, 2013 9:03:08 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SampleChat/jquery/hello.js] in DispatcherServlet with name 'dispatcher'
Apr 8, 2013 9:03:09 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SampleChat/jquery/jquery-1.9.1.js] in DispatcherServlet with name 'dispatcher'
我需要調用JavaScript函數來獲取警報。
好的答案是肯定讚賞的。
顯示我沒有看到你的JSP任何'' – Givi 2013-04-08 15:31:51
我添加了外部腳本。請參閱'和 '' – 2013-04-08 15:32:35