@ResponseBody
@RequestMapping(value="/getUserInfoById.do")
public User getUserById(Long userId)
throws com.controller.interceptor.LoginException{
User user = new User();
if(userId == null){
throw new LoginException();
}
user = userService.selectByPrimaryKey(userId);
if(user == null){
throw new LoginException();
}
return user;
}
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(value = HttpStatus.UNAUTHORIZED reason="没有权限")
public class LoginException extends Exception {
}