mandag 28. mars 2011

JSON controller example

@Controller
@RequestMapping("/boliglan/ajax")
public class FinnCodeAjaxController {

    @Autowired
    private FinnCodeService finnCodeService;

    @RequestMapping(value = "/finncode.json", method = RequestMethod.GET)
    @ResponseBody
    public PropertyAdvert getPropertyInfo(@RequestParam String finnCode) {

        PropertyAdvert propertyAdvert = finnCodeService.findPropertyInfoByFinnCode(finnCode);

        if (propertyAdvert == null) {
            return new PropertyAdvert();
        }

        return propertyAdvert;
    }
}

Ingen kommentarer:

Legg inn en kommentar