您好,登錄后才能下訂單哦!
廢話不多說,直接上代碼
public class DZFP_jdbc extends HttpServlet{ private static final long serialVersionUID = 1L; public static Connection conn; public static ResultSet rs = null ; public static PreparedStatement ps = null ; private static String url = "jdbc:oracle:thin:@192.168.100.11:1111:CRM"; private static String name = "name"; private static String pwd = "pwd"; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { /*PreparedStatement ps; ResultSet rs = null;*/ response.setCharacterEncoding("utf-8"); request.setCharacterEncoding("utf-8"); response.setHeader("content-type", "text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); *********** out.print("{\"errorno\":[{\"list\":error}]}"); } } $.ajax({ type: "post", url: "DZFP_jdbc", dataType: "text", data : { taxcode : taxcode, mobilenum : mobilenum }, timeout : 50000, success: function (data) { var jsonobjs = eval("(" + data + ")"); var list = jsonobjs.errorno[0].list; }, error: function() { alert("網絡異常,請稍后重試"); } }); <servlet> <servlet-name>DZFP_jdbc</servlet-name> <servlet-class> weishijiestudio.hangxinwx.servlet.DZFP_jdbc </servlet-class> </servlet> <servlet-mapping> <servlet-name>DZFP_jdbc</servlet-name> <url-pattern>/DZFP_jdbc</url-pattern> </servlet-mapping>
以上這篇javaweb中ajax請求后臺servlet(實例)就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持億速云。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。