前提・実現したいこと
Springを触り始めたばかりで、簡単なことすらまだ呑み込めていない状態だと思います。
こんなことも分からないの?と思うかもしれませんが、どうか力を貸してください。
Springレガシー・プロジェクトで生成しています。
SpringMVCを用いた、メニュー画面と業務画面の画面遷移の実装。
「業務画面1をクリック」
メニュー画面 ⇒ 業務画面1
「戻るボタンをクリック」
メニュー画面 ⇐ 業務画面1
発生している問題・エラーメッセージ
実装方法が分からない。Springについての理解が足りていない。
アノテーション、コントローラー、xml、JSP等々の関連・紐付の理解が不十分。
また、聞きなれない単語が多いことが理解できないことに拍車をかけていると思う。
ソースをいじるなどをしてはみたが、メニュー画面から業務画面へ画面遷移しようとすると、以下が表示される。
HTTP Status 404 - Not Found
type Status report
messageNot Found
descriptionThe requested resource is not available.
Payara Server 4.1.2.174 #badassfish
MenuScreen.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ page session="false" %> <html> <head> <title>MenuScreen</title> </head> <body> <a href="./hellowebapplication/BusinessScreen">業務画面へ</a> </body> </html>
BusinessScreen.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>BuisinessScreen</title> </head> <body> <a href=".">メニュー画面へ</a> </body> </html>
MenuScreenController.java
package com.example.hellowebapplication; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; /** * Handles requests for the application home page. */ @Controller public class MenuScreenController { /** * Simply selects the home view to render by returning its name. */ @RequestMapping(value = "/", method = RequestMethod.GET) public String home() { return "MenuScreen"; } }
BusinessScreenController.java
package com.example.hellowebapplication; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping("BusinessScreen") public class BusinessScreenController { @RequestMapping public String index(Model model) { return "BusinessScreen"; } }
試したこと
おもに以下のサイトを見ながら試行錯誤ソースを修正し、ブラウザからリンクをクリックした。
https://terasolunaorg.github.io/guideline/public_review/Overview/FirstApplication.html
http://tech.pjin.jp/blog/2016/05/30/springframework4/
http://teqspaces.com/Spring/3
https://sites.google.com/site/soracane/home/springnitsuite/spring-mvc/05-shi-jinosanpuru
補足情報(FW/ツールのバージョンなど)
Pleiades Eclipse 4.6 neon
JDK:Java8を使用(Pleiades梱包のJDKを使用)
payara-4.1.2.174
Spring Tool Suite(STS) for Eclipse 3.9.2 RELEASE
回答2件
あなたの回答
tips
プレビュー