私はSpring MVCに基づいてコントローラを作成しました。 ;私は "http://localhost/app/hello" にアクセスすると、私は404を得る"http:// localhost/app/hello"と "http:// localhost/app/hello /"の違いは何ですか?
@Controller
@RequestMapping("/hello")
public class JsonController {
@RequestMapping(value="/",method=RequestMethod.GET)
@ResponseBody
public Person service(){
Person person=new Person();
person.setId(3);
person.setName("666");
return person;
}
"http://localhost/app/hello/"にアクセスすると、202 OKになります。 "http://localhost/app/hello"と "http://localhost/app/hello/"の違いは何ですか?
まあ有効な応答を返します
'@RequestMapping(value ="/"、method = RequestMethod.GET)'で 'service()'関数を終了し、最後に '/'のないURLは何もマッピングされません。あなたが残りのAPIに何も割り当てられていないURLを呼び出すと、自然に404が得られます。 – Nico