2つのjspの間でデータを転送するのに苦労しています。隠しフィールドを使用してjspの間でデータを渡す
JSP1はwebcamfile
document.getElementById("webcamfile").toString = image_path;
alert(document.getElementById("webcamfile").toString = image_path);
そして
(JSP1でボタンによってactioned)
<form action="jsp2.jsp" method="POST" enctype="multipart/form-data" onsubmit="return validate();">
<input type="hidden" name="webcamfile" id="webcamfile" value=""/>
JSP2
String camera[] = request.getParameterValues("webcamfile"); System.out.println(camera);
Iに(アップロード/ Test.jpgを含有する)IMAGE_PATHを置きます試してみた(jsp1の適切な設定で)
String camera = String.valueOf (request.getParameter("webcamfile"));
String camera = request.getSession().getAttribute("webcamfile").toString();
String camera = request.getParameter("webcamfile").toString();
何も出力していない、何が間違っていますか? (JSP2で)その後、
私は(JSP1で)値を修正した場合でも<input type="hidden" name="webcamfile" id="webcamfile" value="12345"/>
そして
String camera[] = request.getParameterValues("webcamfile");
String camera2 = request.getParameter("webcamfile").toString();
String camera3 = String.valueOf (request.getParameter("webcamfile"));
String camera4 = request.getParameter("webcamfile");
System.out.println(camera);
System.out.println(camera2);
System.out.println(camera3);
System.out.println(camera4)
何もコンソールに表示されません。
本来の意図は、画像ファイルへのパス名を渡すことだった -
var image_path = RegExp.$1;
var image_path = image_url.substring(image_url.indexOf("uploads", 8));
alert(image_path);
(IMAGE_PATHで)パス名はアップロード/ Test.jpg
あるしかし、単に転送するための準備に次のようにやって)アップロードの代わりに数値を入れ
document.getElementById("webcamfile").value = image_path;
ATERを私は仕事にイテレータを得ることができ、いくつかのあい(これを(私が欲しいいけないこれ、私がアップロード/ Test.jpgをしたいです)置く12345)
if (itemx.getFieldName().equals("webcamfile"))
{
webcamfile=itemx.getString();
だから、どのように私が取得する値=ビットへのIMAGE_PATHまたはwebcamfile(私は文字列であると仮定している)のいずれか?
<input type="hidden" name="webcamfile" id="webcamfile" value=""/>
よろしく アクティブ
これは機能しています。一度それを使用したら私に知らせてください。 –
構文エラー、変数宣言子を挿入します。 – Active
あなたはそれをどのように使用したのかを投稿できますか? jsp2.jspのコードを投稿してください。 –