Springmvc-xml
提供:Dev Guides
Spring MVC-XMLの生成の例
次の例は、Spring Web MVCフレームワークを使用してXMLを生成する方法を示しています。 はじめに、作業中の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 Java classes User and UserController under the com.finddevguidespackage. |
3 | The final step is to create the content of the source and configuration files and export the application as explained below. |
User.java
UserController.java
TestWeb-servlet.xml
ここでは、XMLマップされたPOJOユーザーを作成し、UserControllerでユーザーを返しました。 Springは RequestMapping に基づいてXML変換を自動的に処理します。
ソースファイルと構成ファイルの作成が完了したら、アプリケーションをエクスポートします。 アプリケーションを右クリックし、[エクスポート]→[WARファイル]オプションを使用して、 TestWeb.war ファイルをTomcatのwebappsフォルダーに保存します。
次に、Tomcatサーバーを起動し、標準ブラウザーを使用してwebappsフォルダーから他のWebページにアクセスできることを確認します。 URLを試してください– http://localhost:8080/TestWeb/mahesh 。次の画面が表示されます。