session。。缓存
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;
import com.entity.Food;
import com.entity.User;
import com.servie.UserService;
import com.sun.javafx.sg.prism.NGShape.Mode;
import com.until.FoodUntil;
import com.until.WebUntilImpl;
import com.until.Webuntil;
@Controller
@RequestMapping("/user.do")
@SessionAttributes("foods")
public class UserAction {
@Autowired
private UserService userService;
private HttpServletRequest request;
private HttpServletResponse response;
@RequestMapping(params="method=login")
public ModelAndView login(String uname,String upwd){
User u=userService.U_login(uname, upwd);
System.out.println(u);
ModelAndView view=new ModelAndView();
Map<String,User> map = new HashMap<String,User>();
map.put("user", u);
view.addAllObjects(map);
view.setViewName("/page/admin/main");
return view;
}
@RequestMapping(params="method=date_add_type")
public ModelAndView date_add_type(){
Webuntil until=new WebUntilImpl();
FoodUntil foodUntil= until.All_type();
userService.date_add_BigType(foodUntil.getBigTypes());
userService.date_add_FoodType(foodUntil.getFoodTypes());
ModelAndView view=new ModelAndView();
view.setViewName("/page/admin/main");
return view;
}
@RequestMapping(params="method=date_add_food")
public ModelAndView date_add_food(){
Webuntil until=new WebUntilImpl();
for(int i=1;i<360;i++){
userService.date_add_food(until.All_food(i));
}
ModelAndView view=new ModelAndView();
view.setViewName("/page/admin/main");
return view;
}
///---------------------------------------公共操作---------------------------------------------------
@RequestMapping(params="method=find_all_food")
public ModelAndView find_all_food(){
ModelAndView view=new ModelAndView();
List<Food> foods=userService.find_all_food();
Map<String,List<Food>> map = new HashMap<String,List<Food>>();
map.put("foods", foods);
view.addAllObjects(map);
ModelMap model=new ModelMap();
model.addAttribute("foods", foods);
System.out.println(foods.size()+"======000000");
view.setViewName("redirect:/page/publ/index.jsp");
return view;
}
}