更改绝对路径
href="/spring/demo/admin/
##创建UserContronller
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zz.model.User;
import com.zz.respository.ComputerRepository;
import com.zz.respository.UserRepository;
@RestController
public class UserContronller {
@Resource
private UserRepository userRepository;
@RequestMapping("log")
public Map login(User user) {
System.out.println(user.getName());
Map rs=new HashMap();
User u=userRepository.findByNameAndPwd(user.getName(), user.getPwd());
System.out.println(u);
if(u!=null) {
System.out.println(u.getId());
rs.put("rs","y");
}else {
rs.put("rs","n");}
return rs;
}
创建UserRepository
package com.zz.respository;
import org.springframework.data.repository.CrudRepository;
import com.zz.model.User;
public interface UserRepository extends CrudRepository<User, Long>{
public User findByNameAndPwd(String name,String pwd);
}