springmvc与ajax交互
Posted liyafeng
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springmvc与ajax交互相关的知识,希望对你有一定的参考价值。
Jsp页面:
需要引入jquery-1.10.2.min.js、json2.js、jquery.json-2.3.js三个文件
<%@ page contentType="text/html; charset=utf-8" language="java"
errorPage=""%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>springmvc与Ajax交互</title>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/json2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.json-2.3.js"></script>
<link href="<%=request.getContextPath()%>/css/newmain1.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h3></h3>
<form id="form1" action="<%=request.getContextPath()%>/User/saveUser" method="post" onsubmit="return chkInfo(this);">
<div class="right_main" align="center" id="div_operate">
<div class="form_title" style="width: 60%">
<div class="title_leftbg"></div>
<div class="title_nr">用户信息</div>
<div class="title_rightbg"></div>
</div>
<div class="right_bg" style="width: 60%">
<div class="right_main">
<table width="60%" border="1" align="center" class="table_normal">
<tr>
<td width="25%" style="text-align: right;">姓名: </td>
<td style="text-align: left;">
<input type="text" id="userName" name="user_name" size="25" value="${User.user_name }"/>
<span class="xing">*</span>
</td>
</tr>
<tr>
<td width="25%" style="text-align: right;">性别: </td>
<td style="text-align: left;">
<select id="userSex" name="user_sex" style