首先获取到地址栏中的网址,然后找到参数。
var url = window.location.href
var num = url.indexOf('?')
var str = url.substring(num + 1, url.length)
var arr = str.split('=')
arr[1]就是你需要的参数了。
1 给你个解决方法.。2 * @author bzwang**/
public class DynInfo2Html {/*** 将信息转化为静态html
* @param sSourceUrl 动态信息访问URL
* @param sDestDir 存储为静态文件的目录
* @param sHtmlFile 生成的静态文件名,可以按信息的唯一ID+.html命名
* @throws IOException*/public static void convert2Html(String sSourceUrl,String sDestDir,String sHtmlFile) throws IOException{int HttpResult
URL url=new URL(sSourceUrl)
URLConnection urlconn=url.openConnection()
urlconn.connect()
HttpURLConnection httpconn=(HttpURLConnection)urlconn
HttpResult=httpconn.getResponseCode()
if(HttpResult!=HttpURLConnection.HTTP_OK) {}else {InputStreamReader isr =
new InputStreamReader(httpconn.getInputStream())
BufferedReader in = new BufferedReader(isr)
String inputLine
if(!sDestDir.endsWith("/"))sDestDir+="/"
FileOutputStream fout = new FileOutputStream(sDestDir+sHtmlFile)
while ((inputLine = in.readLine()) != null) {
fout.write(inputLine.getBytes())}in.close()fout.close()}}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)