package com.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.bean.Food;
import com.bean.Person;
import com.bean.User;
import com.service.IFoodService;
@Controller
public class FindFoodListController {
@Resource
private IFoodService foodService;
@RequestMapping("/findFoodList")
public ModelAndView queryFoodList(@RequestParam("typeId") int typeId) {
List<Food> list = foodService.getFoodListByType(typeId);
ModelAndView modelView = new ModelAndView();
Map<String, Object> modelMap = new HashMap<String, Object>();
modelMap.put("FOOD_LIST", list);
modelMap.put("TYPE_ID", typeId);
modelView.addAllObjects(modelMap);
return modelView;
}
// model={"id":1,"username":"zhangsan","password":234,"sex":"1"}
@RequestMapping("/jsonPost")
@ResponseBody
public String addUser(@RequestBody User user) {
System.out.println("come in ");
System.out.println(user.getUsername());
return "1";
}
@RequestMapping(value = "/person/login2", method = RequestMethod.POST)
public @ResponseBody
Person login(@RequestBody Person person) {
return person;
}
@RequestMapping(value = "/person/login", method = RequestMethod.POST)
public @ResponseBody
String login2(@RequestBody JSONObject jsonObj) {
return jsonObj.getString("name");
}
}
评论8
最新资源