SpringMvc跳转报404问题**
代码如下
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.ModelAndView;
import cn.an.ssm.model.k_commodity;
import cn.an.ssm.server.CommodityServer;
@Controller
public class CommodityController {
@Autowired
private CommodityServer commodityServer;
@RequestMapping(“/getCommodity”)
public ModelAndView getCommodity(){
ModelAndView mv=new ModelAndView();
k_commodity commodity= commodityServer.getCommodityById(“111110”);
mv.addObject(“commodity”, commodity);
mv.setViewName(“jsp/index1”);
return mv;
}
mv.setViewName(“jsp/index1”)中的地址为index1,但是始终跳转到getCommodity.jsp
这个架包倒入错误,
org.springframework.web.portlet.ModelAndView
该导入
org.springframework.web.servlet.ModelAndView;