spring mvc ajax
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<script type="text/javascript" src="${ctxStatic}/jquery/jquery-1.9.1.min.js"></script>
<title>Insert title here</title>
<script type="text/javascript">
function ajaxTest(){
$.ajax({
data:"name="+$("#name").val(),
type:"GET",
dataType: 'json',
url:"${ctx}/user/logindo.do",
error:function(data){
//alert("出错了!!:"+data.msg);
$("#result").html("出错了!!:"+data.msg) ;
},
success:function(data){
//alert("success:"+data.msg);
$("#result").html(data.msg) ;
}
});
}
</script>
</head>
<body>
<input type="text" name="name" id="name"/>
<input type="submit" value="登录" onclick="ajaxTest();"/>
<div id="result"></div>
</body>
</html>
controller
package com.thinkgem.jeesite.modules.test.web; import java.io.IOException;
import java.util.HashMap;
import java.util.Map; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; /**
* 登录controller
*
* @author Administrator
*
*/
@Controller
@RequestMapping("${adminPath}/user")
public class LoginssController {
@RequestMapping(value="logindo.do")
public @ResponseBody Map<String,Object> login(HttpServletRequest request,HttpServletResponse response) throws IOException{
System.out.println(request.getParameter("name"));
String name = request.getParameter("name"); Map<String,Object> map = new HashMap<String,Object>();
if(name == null) return map;
if(request.getParameter("name").equals("123")){
System.out.println("城东");
map.put("msg", "成功");
}else{
System.out.println("失败");
map.put("msg", "失败");
}
return map;
} @RequestMapping(value="loginss.do")
public String aaa() {
return "modules/test/aaa";
}
}
spring mvc ajax的更多相关文章
- spring mvc ajax 提交复杂数组类型
The server refused this request because the request entity is in a format not supported by the reque ...
- spring mvc ajax异步文件的上传和普通文件上传
表单提交方式文件上传和ajax异步文件上传 一:首先是我在spring mvc下的表单提交方式上传 ssm的包配置我就不一一详细列出来了,但是上传的包我还是列出来 这一段我也不知道怎么给大家讲解就是直 ...
- Spring MVC+ajax进行信息验证
本文是一个ajax结合Spring MVC使用的入门,首先我们来了解一下什么是Ajax AJAX 不是新的编程语言,而是一种使用现有标准的新方法.AJAX 最大的优点是在不重新加载整个页面的情况下,可 ...
- spring mvc ajax请求
jar包中增加 jackson-annotations-2.5.0.jar jackson-core-2.5.0.jar jackson-databind-2.5.0.jar springmvx.xm ...
- Spring MVC ajax:post/get 的具体实现
Post 方式 1.自动注入 a. pom.xml ---- 配置Maven,添加必要的jar包 <!--用于 String-JSONObject 转换 --> <dependenc ...
- spring mvc ajax 400解决
The request sent by the client was syntactically incorrect. ajax发起请求时报400错误.请求代码如下: var reportId=($( ...
- spring mvc ajax返回值乱码
加入如下配置: <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHan ...
- spring mvc+ajax分页
分页大致思路:页面每次把当前页传到后台并获得从后台传过来的json数据,解析后布局到这个页面上. 1.服务端代码: @Controller public class MemcachedContrlle ...
- Spring MVC Ajax 嵌套表单数据的提交
概述 在一些场景里,某个大表单里常常嵌套着一个或若干个小逻辑块,比如以下表单里"设计预审"中包括了一个子模块表单"拟定款项". 在这种情况下该怎么去设计实体类以 ...
随机推荐
- webrtc之视频显示模块--video_render
在上一篇博文中,简单介绍了webrtc为我们提供了跨平台的视频采集模块,这篇博文也简单介绍下webrtc为我们提供的跨平台的视频显示模块:video_render. 该模块的源码结构如下: 如上图,我 ...
- w530 在ubuntu 12.04 _x64 背光调节方法
So to get the screen brightness keys working with your Nvidia graphics card, create a file in the xo ...
- android 开发中判断网络是否连接的代码
在android的开发中,尤其是与访问网络有关的开发,都要判断一下手机是否连接上了网络,下面是一个判断是否连接网络的嗲吗片段: package cn.com.karl.util; import com ...
- jquery中ajax的dataType属性包括哪几项
参考ajax api文档:http://www.w3school.com.cn/jquery/ajax_ajax.asp dataType类型:String预期服务器返回的数据类型.如果不指定,jQu ...
- Ceph的Block分析
一个块是一个连续的字节序列(例如一个512字节的连续数据是一个块).基于块的存储接口通常是旋转介质,例如磁盘.光盘.软盘等.块设备接口的普及使得可以用虚拟的块设备成为和大容量数据存储系统交互的接口,如 ...
- 在fedora 20下使用ssh server
在红帽和centos下,一般安装完后会自带ssh,然后可以通过/etc/init.d/sshd start的方式运行,但是在Fedora 20下,系统改用了另外一套服务开启机制. 首先安装ssh se ...
- hdu 1596 find the safest road
http://acm.hdu.edu.cn/showproblem.php?pid=1596 #include <cstdio> #include <cstring> #inc ...
- Windows文件居然有解锁一说,并且还会引起SignTool Error,真是昏倒!
I'm running Windows 7 and when I try to run a batch file, it says, "The publisher could not be ...
- svn: “sqlite: attempt to write a readonly database”
原因很可能是在svn与本地同步的时候上锁了,可能没注意在svn执行与仓库同步的时候被中断,所以锁文件没有解锁,但是这样的错误,应该不是标题上所说的错误啊??搞不懂了,以前这样的错误,cleanup都有 ...
- The Angles of a Triangle
The Angles of a Triangle You are given the lengths for each side on a triangle. You need to find all ...