「Spring入門」@RequestMappingのvalue属性の基本的使い方

1.URLを指定
@RequestMapping(value = “/address")

2.value属性自体を省略
@RequestMapping()
@RequestMapping(“/")

3.複数指定
@RequestMapping(value = { “/", “/address" })
@RequestMapping({ “/", “/address" })

4.params属性を利用
@RequestMapping(value = “/cft/address", params = “address1", method = RequestMethod.POST)

@RequestMapping(value = { “/address", “/address/{addressId}" }, params = “method=update")

5.producesを利用
@RequestMapping(value="/address", method=RequestMethod.PUT, produces="text/plain;charset=UTF-8″)
@ResponseBody
jsonを返すことの方が多いです。

6.RequestMethod.GETを利用
@RequestMapping(value = “/address", method = RequestMethod.GET)
画面初期表示の場合よく使います。

Java

Posted by arkgame