【发布时间】:2014-09-08 10:46:32
【问题描述】:
我在我的 jsp 页面中声明了一个简单的变量
<html>
<body>
<c:set var="vehicle" scope="request" value="Car" />
<td><a href="<%=request.getContextPath()%>/productsHome/vehicles">Cars</a></td>
</body>
</html>
我正在尝试在我的 Spring 控制器中访问值为“Car”的变量车辆
@RequestMapping(value = "/vehicles", method = RequestMethod.GET)
public ModelAndView viewLaptops(@RequestParam(value = "vehicle", required = false) String vehicleType) {
if (vehicleType.equals("Car")) {
// retrieve car list, return the model for car list
}
else if (vehicleType.equals("Truck")) {
// retrieve truck list, return the model for truck list
}
System.out.println(carType);
}
但我得到一个空值。我怎样才能实现这一目标?感谢您的帮助。
【问题讨论】:
标签: spring jsp spring-mvc controller