jsp页面的javascript代码:
function change(parm){
..
var path ="你好";
}
这个页面通过struts2跳转,请问在action中如何获取path这个字符串?请给出思路及代码,谢谢!
function change(parm){
..
var path ="你好";
}
这个页面通过struts2跳转,请问在action中如何获取path这个字符串?请给出思路及代码,谢谢!
解决方案 »
- 请教 SSH中文乱码问题
- 重装oracle之后,eclipse里工程连不上oracle了
- J2EE重复执行
- Hibernate中实体类用Serializable和不用Serializable有什么区别???
- Spring搞了两天都没头绪,望有心人指教、、、
- log4j配置问题,xml格式的
- 应该采用什么方法将项目组成员所写的代码合起来?怎样合? (后台是用jb写的ejb,容器weblogic,前台是用jb写的struts)
- 关于sun.jdbc.odbc.JdbcOdbcDriver驱动程序
- 如何将UTF-8编码转换成GB2312编码?
- 请看我的JavaMail为何不能发邮件?有代码。
- 改变图片规格出错
- 求大神
document.forms[0].action = "xxx.action?path=" + encodeURI(encodeURI(path));
document.forms[0].submit();
action
request.getParameter("path");
2. set val into form hidden;
document.getElementById("path").value = path;
<input type="hidden" value="" id="path" />action
private String path;setter/getter;
String path = request.getParameter("path");
path = java.net.URLDecoder.decode(path, "UTF-8");
代码中把这变量设置到request
这样后台才能获取到数据
<s:file name="uploadPic" id="upload" onchange="loadPath()"/>
<s:hidden name="uploadPath" id="path"/>//用来传递上传文件本地路径
function loadPath()
{
//通过ID获取文件域的文件名(包括路径)
var filePath=document.getElementById("upload").value; //将文件名(包括路径)赋予隐藏域
document.getElementById("path").value=filePath;
alert(filePath);
}
以上代码不兼容FIREFOX
{
if(obj)
{
if (window.navigator.userAgent.indexOf("MSIE")>=1)
{
obj.select();
return document.selection.createRange().text;
}
else if(window.navigator.userAgent.indexOf("Firefox")>=1)
{
if(obj.files)
{
return obj.files.item(0).getAsDataURL();
}
return obj.value;
}
return obj.value;
}
} function loadPath()
{
//通过ID获取文件域的文件名(包括路径)
var obj=document.getElementById("upload");
var filePath=getFilePath(obj); //将文件名(包括路径)赋予隐藏域
document.getElementById("path").value=filePath;
alert(filePath);
}
var path = "yourPath";
location.href="yourAction.action?path="+path;Action中:
String path = request.getParameter("path");
document.forms[0].action = "xxx.action?path=" + encodeURI(encodeURI(path));
document.forms[0].submit();
action
request.getParameter("path");
2. set val into form hidden;
document.getElementById("path").value = path;
<input type="hidden" value="" id="path" />action
private String path;setter/getter;、答案了