私はこのサーブレットマッピングを持っています
<servlet-mapping>
<servlet-name>devicesWeb</servlet-name>
<url-pattern>*.do</url-pattern>
<url-pattern>/device-catalogue</url-pattern>
<url-pattern>/device-catalogue/</url-pattern>
<url-pattern>/device-catalogue/*</url-pattern>
<url-pattern>/search/search.do</url-pattern>
</servlet-mapping>
これらの 2 つの方法で:
@RequestMapping(value = "/device-catalogue", method = RequestMethod.GET)
private String initForm(@ModelAttribute("searchForm") final SearchForm searchForm,
BindingResult result, HttpServletRequest request, Model model, Locale locale) {
sessionHelper.checkSessionAttributes(request, locale);
return SEARCH_VIEW;
}
@RequestMapping(value = { "/search/showProductDetails.do", "/device-catalogue/{id}" }, method = { RequestMethod.GET, RequestMethod.POST })
private String showProductDetails(@ModelAttribute("searchForm") final SearchForm searchForm,
HttpServletRequest request, Model model, Locale locale) {
StringTokenizer st = new StringTokenizer(StringEscapeUtils.escapeHtml(searchForm.getItemId()),"=");
if (st.countTokens()>1) {
String awardId=st.nextToken();
String id=st.nextToken();
Item item = deviceService.getItemByAwardId (Long.parseLong(id), awardId);
normalizeWebsiteURL (item);
orderCountriesAvailability(item.getCountriesAvailability(), locale);
model.addAttribute("item", encodeItemForHTML(item));
}
return PRODUCT_DETAIL_VIEW;
}
この URL は正常に機能します。
http://127.0.0.1:7001/eDevices/device-catalog
しかし、これではありません(404を取得しました)!
http://127.0.0.1:7001/eDevices/device-catalog/16720
これをweb.xmlに追加すると動作します
<url-pattern>/product-catalogue/16720</url-pattern>