- 注册时间
- 2017-10-16
- 最后登录
- 1970-1-1
- 阅读权限
- 10
- 积分
- 38
- 精华
- 0
- 帖子
- 0
|
<div id="form1">
<table>
<tr>
<td><label for="username">username:</label></td>
<td><input name="username" class="mini-textbox" required="true" requiredErrorText="帐号不能为空" /></td>
</tr>
<tr>
<td><label for="pwd">pwd:</label></td>
<td><input name="pwd" class="mini-password" vtype="minLength:4"
required="true" minLengthErrorText="密码不能少于4个字符" /></td>
</tr>
<tr>
<td></td>
<td><input value="Login" type="button" id="login"/></td>
</tr>
</table>
</div>
<script type="text/javascript">
mini.parse();
function submitFun(){
var form = new mini.Form("#form1");
form.validate();
if (form.isValid() == false) return;
//提交数据
var o = form.getData();
var json = mini.encode(o);
alert(json)
$.ajax({
url:"${ctx}/login",
data:{info:json},
type: "post",
dataType:"json",
//contentType:"application/json",
cache:false,
success: function (text) {
mini.alert("正确Text"+text);
},
error: function (jqXHR, textStatus, errorThrown) {
mini.alert("textStatus:"+textStatus+"---jqXHR:"+jqXHR+"---errorThrown:"+errorThrown);
}
});
}
后台COntroller:
@ResponseBody
@RequestMapping(value="/login",produces= {"application/json;charset=UTF-8"})
public String login(String info) {
JSONObject jsonObj = JSONObject.fromObject(info);
@SuppressWarnings("unchecked")
Map<String,String> map = (Map<String,String>)jsonObj;
String username = map.get("username");
String pwd = map.get("pwd");
System.out.println("username=="+username+" pwd==="+pwd);
|
|