jsp页面:
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>登录验证
欢迎登录
后台控制类:
package com.login.control;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSONObject;
import com.login.bean.Users;
import com.login.service.UsersService;
/**
* 用户控制类
* @author
*
*/
@Controller
public class UsersControl {
@RequestMapping(value="ajax1.action",method= RequestMethod.POST) @ResponseBody
public Object ajax1(HttpServletRequest request){
System.out.println("进入控制类");
JSONObject json = new JSONObject();
String ms = "ajax测试1成功!哈哈!";
json.put("ms", ms);
System.out.println("出控制类");
return json;
}
}必须加这两句才能返回json值
@RequestMapping(value="ajax1.action",method= RequestMethod.POST) @ResponseBody










