package com.ecai.front.controller;
import java.util.List;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.ecai.bean.Product;
import com.ecai.bean.User;
import com.ecai.front.service.SearchService;
/**
* <p>Title: IndexController</p>
* <p>Description: </p>
* @author TF
* @date 2018年4月30日
*/
@Controller
public class IndexController {
@Autowired
private SearchService SearchService;
@RequestMapping(value="index")
public String list(String keywords, Model model) throws Exception{
List<Product> list = SearchService.searchBykeywords(keywords);
model.addAttribute("list", list);
System.out.println(list);
return "home/search";
}
@RequestMapping("detail/{id}")
public ModelAndView productDetail(@PathVariable("id")String id,ModelAndView mav) throws Exception{
Product product = SearchService.searchByid(id);
mav.addObject("detail", product);
mav.setViewName("home/detail");
return mav;
}
</
import java.util.List;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.ecai.bean.Product;
import com.ecai.bean.User;
import com.ecai.front.service.SearchService;
/**
* <p>Title: IndexController</p>
* <p>Description: </p>
* @author TF
* @date 2018年4月30日
*/
@Controller
public class IndexController {
@Autowired
private SearchService SearchService;
@RequestMapping(value="index")
public String list(String keywords, Model model) throws Exception{
List<Product> list = SearchService.searchBykeywords(keywords);
model.addAttribute("list", list);
System.out.println(list);
return "home/search";
}
@RequestMapping("detail/{id}")
public ModelAndView productDetail(@PathVariable("id")String id,ModelAndView mav) throws Exception{
Product product = SearchService.searchByid(id);
mav.addObject("detail", product);
mav.setViewName("home/detail");
return mav;
}
</