我正在使用Java Spring框架来映射我的一部分数据中的数据,而@pathvariable无法让我访问任何数据.所有我;我进入控制台是
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.List;
@GetMapping()
public Iterable<Adventure> getAllAdventures(){
return this.adventureRepository.findAll();
}
@GetMapping("/bycountry/{country}")
public List<Adventure> getByCountry(@PathVariable("country") String country){
return this.adventureRepository.findByCountry(country);
}
我的数据是通过sql输入的,我使用这个接口来访问数据
public interface AdventureRepository extends CrudRepository<Adventure, Integer> {
public List<Adventure> findByCountry(String country);
public List<Adventure> findByState(String state);
}