Java项目中jsp页面取不到表单中hidden标签里的值
夜炫音 2011-03-16 03:12:14 环境:两个服务器A和B,两个java应用程序A负责传参B负责接收参数,A应用程序在A服务器上,B应用程序在B服务器上
实现功能:使用两个服务器实现图片上传,一个服务器负责上传界面显示,另一个服务器负责后台上传实现,然后把图片地址传给服务器一显示图片
问题:B服务器中的应用程序B通过request.getParameter("htmlEditorBasePath")取不到值
具体代码:
应用程序A重要代码:
<body>
<form action="http://192.168.0.67:80/htmlEditor/showImage/upload4htmleditor.jsp" method="post" enctype="multipart/form-data" name="upformHtmlEditor1" >
<input type="hidden" name="forwardPath" value="/yysHtmlEditor/showPicture?htmlId=HtmlEditor1">
<input type="hidden" name="htmlEditorBasePath" value="http://localhost:8082/lnyhxs/">
<input type="hidden" name="htmlId" value="HtmlEditor1">
<input type="hidden" name="uploadedFileProcessor" value="yys.htmleditor.PictureProcessor" />
<input name="file" id="file" type="file" class="input" />
<input type="hidden" name="dateFormat" value="">
<input type="hidden" name="uploadPath" value="temp">
<input name="Submit" type="submit" class="button" value="上传" />
</form>
</body>
B服务器上应用程序B重要代码:
<%
SmartUpload mySmartUpload =new SmartUpload();
long file_size_max=4000000;
String fileName2="",ext="",testvar="";
String url="updateImage/";
String htmlEditorBasePath=request.getParameter("htmlEditorBasePath"); //问题所在,取不到值
String htmlId=request.getParameter("htmlId"); //问题所在,取不到值
mySmartUpload.initialize(pageContext);
try {
mySmartUpload.setAllowedFilesList("jpg,gif,JPG,GIF");//此处的文件格式可以根据需要自己修改
//上载文件
mySmartUpload.upload();
} catch (Exception e){
e.printStackTrace();
%>
<SCRIPT language=javascript>
alert("只允许上传.jpg和.gif类型图片文件");
window.history.go(-1);
</script>
<%
}
try{
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
if (myFile.isMissing()){%>
<SCRIPT language=javascript>
alert("请先选择要上传的文件");
window.history.go(-1);
</script>
<%}
else{
//String myFileName=myFile.getFileName();
ext= myFile.getFileExt();
int file_size=myFile.getSize();
String saveurl="";
if(file_size<file_size_max){
Calendar calendar = Calendar.getInstance();
String filename = String.valueOf(calendar.getTimeInMillis());
Date dt =new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM");
String strTime=sdf.format(dt)+"/";
saveurl=application.getRealPath("/")+url+strTime;
File file =new File(saveurl);
if(!file.exists()){
file.mkdir();
}
saveurl+=filename+"."+ext;
myFile.saveAs(saveurl,SmartUpload.SAVE_PHYSICAL);
String httpUrl=url+strTime+filename+"."+ext;
%>
<html>
<head>
<title>图片</title>
<a href=URL target="image"></a>
</head>
<body onload="load();">
<form name="form1" method="post" action="<%=htmlEditorBasePath %>/yysHtmlEditor/showPicture">
<input name="uploadUrl" type="hidden" value="http://192.168.0.67/htmlEditor/<%=httpUrl%>">
<input name="htmlId" type="hidden" value="<%=htmlId %>">
</form>
</body>
<script>
function load(){
document.form1.submit();
}
</script>
</html>
<%
}
}
}catch (Exception e){
out.print(e.toString());
}
%>