4 ŞUBAT 2011, Cuma
BAHAR 3.0, isteğe bağlı bir yol yapabilir miyim değişken
BAHAR 3.0, isteğe bağlı bir yol bir değişken yapabilirim? Gibi
@RequestMapping(value="/json/{type}",method=RequestMethod.GET)
public @ResponseBody TestBean testAjax(HttpServletRequest req,@PathVariable String type,@RequestParam("track") String track) {
return new TestBean();
}
Burada /json/abc /json aynı yöntemi çağırmak istiyorum.
@RequestMapping(value="/json",method=RequestMethod.GET)
public @ResponseBody TestBean testAjax(HttpServletRequest req,@RequestParam(value="type",required=false) String type,@RequestParam("track") String track) {
return new TestBean();
}
ve sonra /json?type=abc&takip=aa /json?parça=rr çalışacak
CEVAP
5 ŞUBAT 2011, CUMARTESİ
İsteğe bağlı yol değişkenleri olamaz, ama aynı hizmet kod adını verdikleri iki kontrolör yöntemleri var
@RequestMapping(value="/json/{type}", method=RequestMethod.GET)
public @ResponseBody TestBean typedTestBean(HttpServletRequest req, @PathVariable String type, @RequestParam("track") String track) {
return getTestBean(type);
}
@RequestMapping(value="/json", method=RequestMethod.GET)
public @ResponseBody TestBean testBean(HttpServletRequest req, @RequestParam("track") String track) {
return getTestBean();
}
Bunu Paylaş:
Nasıl T-SQL saklı yordam isteğe bağlı ...
Nasıl isteğe bağlı giriş bağımsız deği...
C# 4.0: varsayılan değeri isteğe bağlı...
Nasıl bir yönlendirme sayfası jQuery k...
Nasıl Python fonksiyonu dekoratörler z...