Spring MVC コントローラーを理解しようとしています。しかし、相対パスに問題があります
私はページを持っています:
http://localhost:8080/jeeniweb/articles
そのページにはメニューオプションがあります:
<li><a href="articles/writing_great_code/structure_and_dependencies/">Structure and Dependencies</a></li>`
これは、ブラウザーでは次のように解決されます。
http://localhost:8080/jeeniweb/articles/writing_great_code/structure_and_dependencies/
ユーザーがこのリンクをクリックすると、コントローラーでこのリクエストをインターセプトします。
@RequestMapping(value = "/articles/{article}/{chapter}")
public String articles(@PathVariable String article, @PathVariable String chapter)
{
System.out.println("Articles Page Request");
System.out.println("article: " + article);
System.out.println("chapter: " + chapter);
return "articles/index";
}
このメソッドはリクエストをキャッチし、メソッドprintln
は正しいものを出力します。しかし、私がしたい呼び出しの後:
http://localhost:8080/jeeniweb/articles
しかし、実際にはブラウザは次のようになります:
http://localhost:8080/mysite/articles/writing_great_code/structure_and_dependencies/
articles/index
メソッドから戻ってきたときに、これはどうすればよいですか?
私のサーブレット構成は次のとおりです。
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
私がSpringを理解しているように、これは、上記のコードを処理した後の結果の戻り値/WEB-INF/views/articles/index.jsp
が、私が望むものであることを意味します。そこに index.jsp ページがあります。
どんな助けでも大歓迎です。
ありがとうアダム