jspからControllerにクエリ文字列パラメータを取得できません。以下はjspからSpringへのGETアクションでControllerがurlクエリ文字列パラメータを削除します
私uploadSuccess.jspコードです:
春コントローラの方法がある
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<html>
<head>
<title>File Upload Success</title>
</head>
<body>
<c:url var="formActionURL" value="http://localhost:8080/scanpipeline/readQRCode">
<c:param name="fileName" value="${fileName}" />
</c:url>
<form method="GET" action="${formActionURL}" >
<h3>
File Uploaded Successfully!
</h3>
<strong>File name is :<%= request.getAttribute("fileName") %> !!</strong>
<strong>Total number of data read from file: <%=request.getAttribute("filedata") %> !!
</strong><br>
<p></p>
If you want to see QR Code information in the upload file, click 'Ok' <br>
<input type="submit" value="Ok">
</form>
</body>
</html>
://
http://localhost:8080/pipeline/readQRCode
@RequestMapping(value = "/readQRCode", method = RequestMethod.GET)
public String readQRCode(Model model, @RequestParam(value = "fileName", required = true) String fileName)
{
........................
}
私は、JSPのソースの表示で見るURLクエリ文字列は次のとおりです。 action = "http:// localhost:8080/pipeline/readQRCode?fileName = Paper + Scan.pdf">
ただし、jspを送信するとフォーム、それは私にHTTPステータス400エラー "必要な文字列パラメータ 'fileName'が存在しません"を提供します。クエリ文字列を削除しますか?それ以降。ご案内ください。前もって感謝します。
ありがとう@Mike。私は試しましたが、出力は同じです。今回私はブラウザでviewourceを実行したとき、同じコードを取得しました:
私は私の答えにいくつかの変更を加えました。フォームの古い動作を使用します。 – Mike
ありがとう@Mike。隠しパラメータで動作します。私はなぜurl文字列にパラメータを追加するときにコントローラメソッドが呼び出されないのか分からなかった。コーディングの方法が間違っていますか? –