是jquery的漏洞,还是我没明白问题的实质?
做自己的一个项目的时候发现遇到了一些问题。
在servlet中的request域中传递一个对象,让jsp页面接受,遇到了一个问题。
在servlet中,实现页面的跳转有重定向和转发。
response.sendRedirect("");
request.getRequestDispatcher("path").forward(request, response);
遇到的问题简化如下
servlet页面:
package servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class TestSer extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.sendRedirect("../test1.jsp");
//request.getRequestDispatcher("../test1.jsp").forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
}
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'test1.jsp' starting page</title>
<script type="text/javascript" src="jquery.js"></script>
<script>
$(document).ready(function() {
alert("test");
});
function test() {
alert("test1");
}
</script>
</head>
<body>
<input type="button" value="按钮" onclick="test();" />
</body>
</html>
<script type="text/javascript" src="../jquery.js"></script>