-2
我無法顯示可能的餐廳。 I.ve了我的控制器類:彈簧mvc url參數
@Controller
public class RestaurantController extends MultiActionController{
private RestaurantDAO restaurantDAO;
public void setRestaurantDAO(RestaurantDAO restaurantDAO) {
this.restaurantDAO = restaurantDAO;
}
@RequestMapping("/restaurant/{restaurantId}")
public ModelAndView restaurantid(@PathVariable("contactId") int id,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
Restaurant restaurant = restaurantDAO.findRestaurantById(id);
ModelMap modelMap = new ModelMap();
modelMap.addAttribute("restaurant", restaurant);
return new ModelAndView("restaurant", modelMap);
}
}
IM我的jsp只是:
<c:out value="${restaurant.name }"
在我爲spring-servlet.xml
:
<bean name="/restaurant/**" class="web.RestaurantController" >
<property name="restaurantDAO" ref="myRestaurantDAO"/>
</bean>
我的錯誤,對不起。但它仍然不起作用 請求的資源(/ RestFinderWebApp/restaurant/48)不可用。 – zax 2011-05-24 13:45:42
將@RequestMapping(「/ restaurant/**」)添加到您的控制器中,並查看找到的映射(彈簧將在啓動時在INFO級別上打印它們) – Ralph 2011-05-24 13:50:07
我改變了像你告訴我那樣做,但它最早工作。 MultiActionController:import org.springframework.web.servlet.mvc.multiaction.MultiActionController; – zax 2011-05-24 13:51:59