js代码:
其中oneCate、docLib_PUB分别是两个select元素的id
- JScript code
$.ajax({ type : "post", url : "CompareProgramServlet", data : {catID:$('#oneCate').val(),docLibID_PUB:$('#docLib_PUB').val}, success : function (data){ alert(typeof data); } });
servlet部分代码:
- Java code
public class CompareProgramServlet extends HttpServlet {public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println("!!!!!!!!!!!"); request.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8"); String catID=request.getParameter("catID"); String docLibID_PUB = request.getParameter("docLibID_PUB");
web.xml配置:
- XML code
<servlet> <servlet-name>CompareProgramServlet</servlet-name> <servlet-class>compareProgram.CompareProgramServlet</servlet-class> </servlet><servlet-mapping> <servlet-name>CompareProgramServlet</servlet-name> <url-pattern>/servlet/CompareProgramServlet</url-pattern> </servlet-mapping>
------解决方案--------------------------------------------------------
请求路径应该是 servlet/CompareProgramServlet 吧
------解决方案--------------------------------------------------------
url问题
------解决方案--------------------------------------------------------
<url-pattern>/servlet/CompareProgramServlet</url-pattern>
>/servlet/CompareProgramServlet这个才是
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
1、
- HTML code
$.ajax({ type : "post", url : "CompareProgramServlet", data : {catID:$('#oneCate').val(),docLibID_PUB:$('#docLib_PUB').val[color=#FF0000]()[/color]}, success : function (data){ alert(typeof data); } });