jsp 中获取 <input type = file id ="filePath" name= "filePath"> 的路径

jsp 中获取 <input type = file id ="filePath" name= "filePath"> 的路径,第1张

我测了,这段代码是可以的,你检查一下是不是其他问题,顺便提示一下获取路径以后最好做一下编码格式转化,避免出现乱码!String path = requestgetParameter("filePath"); //上传目标地址

if(path!=null&&!pathequals("")){

strUp = new String(pahtgetBytes("ISO-8859-1"), "GB2312");

}

JSP页面

<% String url = requestgetScheme()+"://"+ requestgetServerName()+requestgetRequestURI()+""+requestgetQueryString(); %>

用JS可以的

windowlocationhref

功能比较简单,我就不加注释了。

public class T

{

public static void main(String[] args)

{

String ip="163102999";

String last=ipsubstring(iplastIndexOf("")+1);

Systemoutprintln (last);

}

}

JSP获取用户真实IP地址

(大致原理是这样,但我没有测试过。)

String strIP = "";

String strFF = requestgetHeader("X_Forwarded_For");

if(strFFequals("") || strFF"unknown")>=0 ){

strIP = requestgetLocalAddr();

} else if (strFFindexOf(",")>=0 ){

strIP = strFFsubstring(0, strFFindexOf(","));

} else if (strFFindexOf(";")>=0 ){

strIP = strFFsubstring(0, strFFindexOf(";"));

} else {

strIP = strFF;

}

strIP = strIPsubstring(0, 30)trim();

请求客户端是不是用代理了如果用了代理就不能这么获取了 public String getIpAddr(>

你的错误原因很简单

在a页面,打印的是字符串,所以没有任何错误

但是在b页面,因为是通过url传递过来的。

相当于 bjspurl=>

你是在测试你写的东西吧,你访问的时候是不是输的localhost啊?localhost代表的就是你本机的ip,也就是127001,访问那个页面的时候输入本机的ip地址就好了

以上就是关于jsp 中获取 <input type = file id ="filePath" name= "filePath"> 的路径全部的内容,包括:jsp 中获取 <input type = file id ="filePath" name= "filePath"> 的路径、在jsp中如何取得当前页面完整的URL(带参数)、jsp中如何获取ip地址的最后一段,等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9306328.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-27
下一篇2023-04-27

发表评论

登录后才能评论

评论列表(0条)

    保存