1
私はこれらの2つの方法では、このサーブレット・マッピング春のservlet-mapping/URLパターン
<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>
を持っている:
@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-catalogue
をしかし、この1つではありません(私は404を持っています)!私はweb.xmlに以下を追加した場合
http://127.0.0.1:7001/eDevices/device-catalogue/16720
は、それは、URLごとに<url-pattern>
を書いてはいけません
<url-pattern>/product-catalogue/16720</url-pattern>
MMM .....これをやって、それが私ドンと思われるご
web.xml
であなたのようなものを必要とする、ことを行うために–
あなたの 'WEB-INF'に、' resources'フォルダを作成してください。その中にCSS、画像、フォントなどのフォルダを作成します。今、jspページでこれらのリソースを使用したいときはいつでも、jstlの 'c:url'タグを使います。たとえば、画像を表示すると、 '"> ' –