首页>代码>spring boot整合mybatis实现请求接口返回json数据的简单实例>/spring-boot-mybatis-xml/src/main/java/com/neo/web/UserController.java
                
                package com.neo.web;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.neo.entity.UserEntity;
import com.neo.mapper.UserMapper;
@RestController
public class UserController {
	
	@Autowired
	private UserMapper userMapper;
    @RequestMapping("/")
    public String index() {
        return "Hello World!!!";
    }
	
	@RequestMapping("/getUsers")
	public List<UserEntity> getUsers() {
		List<UserEntity> users=userMapper.getAll();
		return users;
	}
	
    @RequestMapping("/getUser")
    public UserEntity getUser(Long id) {
    	UserEntity user=userMapper.getOne(id);
        return user;
    }
    
    @RequestMapping("/add")
    public void save(UserEntity user) {
    	userMapper.insert(user);
    }
    
    @RequestMapping(value="update")
    public void update(UserEntity user) {
    	userMapper.update(user);
    }
    
    @RequestMapping(value="/delete/{id}")
    public void delete(@PathVariable("id") Long id) {
    	userMapper.delete(id);
    }
    
    
}
最近下载更多
                
                zhaokai0224     LV14
                2023年11月23日
            
            
        
                18669505276     LV4
                2023年5月4日
            
            
        
                xiaolin712     LV9
                2022年3月8日
            
            
        
                crosssky     LV1
                2021年12月19日
            
            
        
                huaua7676     LV30
                2021年9月2日
            
            
        
                yifeiyifei     LV1
                2021年7月19日
            
            
        
                lantian402     LV1
                2021年3月25日
            
            
        
                wangdengzhe     LV7
                2020年12月1日
            
            
        
                aa991215     LV17
                2020年5月23日
            
            
        
                huyuan122     LV1
                2020年5月13日
            
            
        
最近浏览更多
                
                Oxygeni     LV7
                2024年7月13日
            
            
        
                2636804923     LV6
                2024年6月16日
            
            
        
                ma406805131     LV19
                2024年5月11日
            
            
        
                zhaokai0224     LV14
                2023年11月23日
            
            
        
                漫步的海星     LV4
                2023年9月26日
            
            
        
                锦州队长     LV2
                2023年7月27日
            
            
        
                18669505276     LV4
                2023年5月4日
            
            
        
                hbsoft2008     LV16
                2023年2月17日
            
            
        
                cqbscxh     LV11
                2022年9月30日
            
            
        
                笨小孩一号     LV22
                2022年8月2日
            
            
        
                
                
                