63 jQuery-使用ajax()方法发送请求

1.效果图

1.1 /jquery/jquery_ajax 路径下
63 jQuery-使用ajax()方法发送请求_第1张图片
1.2 使用 名称: 大都督, 密码: 123456,点击登录后
63 jQuery-使用ajax()方法发送请求_第2张图片

2.HTML代码

2.1 jquery_ajax.html页面代码




	
    62 jQuery-使用ajax()方法发送请求
    


	

2.2 login.html页面代码

用户登录
名称:
密码:
  

3.Java代码

package com.example.demo.manager;

import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description jquery控制层
 * @author 大都督
 * @date 2019年1月3日
 */
@Controller
@RequestMapping("/jquery")
public class JqueryManager extends BaseManager{
	
	/**
	 * 
	* @Title: confirmLogin 
	* @Description:对用户名和密码进行验证 
	* @param txtName
	* @param txtPass
	* @return 
	* @author 大都督
	* @date 2019年1月5日
	* @return String
	 */
	@RequestMapping("/confirm_login")
	@ResponseBody
	public String confirmLogin(String txtName, String txtPass) {
		System.out.println("txtName:"+txtName+" txtPass:"+txtPass);
		if (StringUtils.equals(txtPass, "123456") && StringUtils.equals(txtName, "大都督")) {
			return "操作提示,登录成功!";
		}
		return "用户名或密码错误!";
	}
	
	/**
	 * 
	* @Title: login 
	* @Description:获取login.html页面 
	* @return 
	* @author 大都督
	* @date 2019年1月5日
	* @return String
	 */
	@RequestMapping("/login")
	public String login() {
		return "jquery/testFile/login";
	}
	
	/**
	 * 
	* @Title: jqueryAjax 
	* @Description:跳转到jquery_ajax页面 
	* @return 
	* @author 大都督
	* @date 2019年1月5日
	* @return String
	 */
	@RequestMapping("/jquery_ajax")
	public String jqueryAjax() {
		return "jquery/ajax/jquery_ajax";
	}

}

你可能感兴趣的:(前端)