package me.yuki.controller;

import me.yuki.po.User;
import me.yuki.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by Ayakura Yuki on 2017/4/10.
 */
@Controller
public class UserController {

	@Autowired
	private UserService userService;

	@RequestMapping("/auth/login/{username}/{password}")
	public String login(@PathVariable String username, @PathVariable String password, Model model) {
		User user = new User();
		user.setUsername(username);
		user.setPassword(password);
		User confirm = userService.loginAuthorization(user);
		if (confirm != null) {
			model.addAttribute("user", confirm);
			return "success";
		}
		else {
			model.addAttribute("username", username);
			return "error";
		}
	}

}

@@ -355,16 +355,77 @@
 Mapping;
+%0Aimport org.springframework.web.bind.annotation.ResponseBody;
 %0A%0A/**%0A *
@@ -1021,10 +1021,409 @@
 %09%09%7D%0A%09%7D%0A%0A
+%09@RequestMapping(%22/auth/loginByJson/%7Busername%7D/%7Bpassword%7D%22)%0A%09@ResponseBody%0A%09public User loginByJson(@PathVariable String username, @PathVariable String password, Model model) %7B%0A%09%09User user = new User();%0A%09%09user.setUsername(username);%0A%09%09user.setPassword(password);%0A%09%09User confirm = userService.loginAuthorization(user);%0A%09%09if (confirm != null) %7B%0A%09%09%09return confirm;%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09return null;%0A%09%09%7D%0A%09%7D%0A%0A
 %7D%0A

Test json