Я пытаюсь смоделировать вызов REST как таковой весной:
guess {game: 'cdaeaa', guess: 'e' }
который выводит следующее:
{gameId: 'cdaeaa', word: '____', incorrect: 1, status: 'ACTIVE'}
Мне необходимо создать функцию, которая принимает два параметра. Должен вернуть данные игры. Класс игры выглядит следующим образом:
public class Game {
private final String gameId;
private final String word;
private String guessedWord;
private Set<Character> guessedChars;
private GameStatus status;
private int incorrectGuesses;
private static final int MAX_TRIES = 7;}
Однако, когда я звоню как таковой:
http://localhost:8080/guess/{asewqd}/{c}
(Неважно, помещу ли я вещи в фигурные скобки или нет.)
Я получаю следующую ошибку:
//POST
//make guess
@RequestMapping(value = "/guess/{game}/{guess}", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public Game makeGuess(@PathVariable String game, @PathVariable String guess, HttpSession session) throws GameDoesNotExistException, InvalidCharacterException{
Game g = getGame(game,session);
String gameId = g.getId();
if(gameId.equals(game) && guess.length() > 0) {
boolean correct = compareWords(guess, g);
if(!correct){
g.incIncorrect_guesses();
}
g.setStatus();
}
else{
if(!gameId.equals(game)) {
throw new GameDoesNotExistException(game);
}
else{
throw new InvalidCharacterException(guess);
}
}
g = getGame(game,session);
return g;
}