跟进
由于新的要求必须在JSP中完成,即使下面原始答案中列出的Spring处理程序代码可以添加具有相关信息的Model属性,下面是如何执行此操作.
类似的两种方式如下:
原始答案
你标记了spring-mvc,这意味着你有这样的东西(如果你发布它会很好):
@Controller
public class ProductController {
@RequestMapping("/Product/UniqueId")
public String uniqueId(Model model,
@RequestParam(path="code" , required=false) String code,
@RequestParam(path="sig" , required=false) String sig,
@RequestParam(path="pod" , required=false) String pod,
@RequestParam(path="circle" , required=false) String circle,
@RequestParam(path="location", required=false) String location,
@RequestParam(path="color" , required=false) String color) {
// code here
}
}
以下是检查“无查询参数”的两种方法:
// Get all parameters in a Map
public String uniqueId(Model model,
...,
@RequestParam Map allParams) {
if (allParams.isEmpty()) {
// no query parameters given
}
// code here
}
// Use the request object
public String uniqueId(Model model,
...,
HttpServletRequest request) {
if (request.getQueryString() == null) {
// no query parameters given
}
// code here
}