首先我在JSP页面上获取一个对象列表,每个都有一个超链接(锚点),然后点击锚点我必须向控制器发送列表索引(surveyId也是最初进入surveyList)但是控制器没有被调用。它返回404.
<body>
<a href="createSurvey.htm" target="contents">Create a new survey</a>
<table border="1" cellpadding="5" cellspacing="5">
<tr>
<td><b>Existing Surveys</b></td>
</tr>
<c:forEach var="survey" items="${surveyList}" varStatus="status">
<tr>
<td>${survey.surveyTitle}</td>
<td><a id="byParameter"
href="<c:url value='/home.htm/${surveyList[status.index].surveyId}' />">Share</a>
</td>
</tr>
</c:forEach>
</table>
</body>
生成URL是需要的,例如:/project/home.htm/15
这是控制器的外观,我尝试过@RequestParam和@PathVariable注释,都返回404.控制器没有被调用。
@Controller
@RequestMapping("/home.htm/parameter/surveyId=1")
public class UserHomeController {
@RequestMapping(value = "/home.htm/{surveyId}", method = RequestMethod.GET)
protected String doSubmit(@PathVariable("surveyId") int surveyId, HttpServletRequest request,
HttpServletResponse response, @ModelAttribute("userSurvey") UserSurvey userSurvey, BindingResult result)
throws AdException {
System.out.println("inside home controller, surveyId:"+surveyId");
return null;
}
}
有人可以帮帮我。