jsp页面:
html>
<meta><title>登录验证</title>
<script></script>
<script>
$(function(){
//ajax验证
$("#ajax1").click(function(){
alert(1);
$.post(
"ajax1.action",
function(result){
alert(2);
alert(result.ms);
}
);
});
});
</script><p>
</p><p></p><h2>欢迎登录</h2>
<p>
</p>
后台控制类:
FilePond 是一个 JavaScript 文件上传库,支持通过拖拽、粘贴和 API 方式处理文件、目录、URL 和 Data URI。它包含内置的图像优化功能、异步分块上传功能,并提供了适用于 React、Vue、Angular 和 Svelte 的适配器。
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










