Springmvc-parametermethodnameresolver
提供:Dev Guides
Spring MVC-パラメーターメソッド名リゾルバーの例
次の例は、Spring Web MVCフレームワークを使用して、Multi Action ControllerのParameter Method Name Resolverを使用する方法を示しています。 MultiActionController クラスは、単一のコントローラー内のメソッドを使用して複数のURLをそれぞれマップするのに役立ちます。
たとえば、URIの場合、上記の構成を使用して-
まず、動作するEclipse IDEを用意し、次の手順に従って、Spring Web Frameworkを使用して動的フォームベースのWebアプリケーションを開発します。
Step | Description |
---|---|
1 | Create a project with a name TestWeb under a package com.finddevguides as explained in the Spring MVC - Hello World chapter. |
2 | Create a Java class UserController under the com.finddevguides package. |
3 | Create a view file user.jsp under the jsp sub-folder. |
4 | The final step is to create the content of the source and configuration files and export the application as explained below. |
UserController.java
TestWeb-servlet.xml
user.jsp
ソースファイルと構成ファイルの作成が完了したら、アプリケーションをエクスポートします。 アプリケーションを右クリックし、[エクスポート]→[WARファイル]オプションを使用して、 TestWeb.war ファイルをTomcatのwebappsフォルダーに保存します。
次に、Tomcatサーバーを起動し、標準ブラウザーを使用してwebappsフォルダーから他のWebページにアクセスできることを確認します。 ここで、URL- http://localhost:8080/TestWeb/user/test?action = home を試してください。SpringWebアプリケーションで問題がなければ、次の画面が表示されます。