本文目錄一覽:
- 1、如何在Java中嵌入IE
- 2、JAVA如何打開IE
- 3、想用Java程序打開個一個IE頁面(post方式)
- 4、java中能不能使任何瀏覽器都能調用ie瀏覽器的打印功能
- 5、如何用java調用IE打開本地網頁文件
如何在Java中嵌入IE
在html中加入java代碼,就是jsp頁面,jsp里可以加入java代碼了,當然也可以調用外部的java。jsp頁面要想運行必須放到容器里,例如最流行的tomcat。
你應該是新手,還不明白概念,所以在網上找些視頻教程看吧,搜索j2ee或者jsp的教程,jsp就是用java程序動態生成html頁面,瀏覽器不能解析java代碼,所以tomcat這種服務器負責解析,生成最終的html
JAVA如何打開IE
用這個代碼
Runtime.getRuntime().exec(“explorer.exe “);
—————-
樓上的兄弟用
Runtime.getRuntime().exec(“iexplore.exe “);
如果IE默認路徑沒有註冊,那麼就只能訪問註冊表來獲得IE的路徑,然後在使用了。
想用Java程序打開個一個IE頁面(post方式)
你的意思是想某個JSP提交一個POST請求嗎?如果是的話那就簡單了。給你段代碼參考下。望採納.
/**
* 向指定URL發送POST方法的請求
* @param url 發送請求的URL
* @param param 請求參數,請求參數應該是name1=value1name2=value2的形式。
* @return URL所代表遠程資源的響應即HTML
* @throws IOException
*/
private static String sendPost(String url, String param) throws IOException {
PrintWriter out = null;
BufferedReader in = null;
String result = “”;
try {
URL realUrl = new URL(url);
// 打開和URL之間的連接
URLConnection conn = realUrl.openConnection();
// 設置通用的請求屬性
conn.setRequestProperty(“accept”, “*/*”);
conn.setRequestProperty(“connection”, “Keep-Alive”);
conn.setRequestProperty(“user-agent”, “Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)”);
// 發送POST請求必須設置如下兩行
conn.setDoOutput(true);
conn.setDoInput(true);
// 獲取URLConnection對象對應的輸出流
out = new PrintWriter(conn.getOutputStream());
// 發送請求參數
out.print(param);
// flush輸出流的緩衝
out.flush();
// 定義BufferedReader輸入流來讀取URL的響應
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += “\n” + line;
}
} catch (IOException e) {
throw e;
}
// 使用finally塊來關閉輸出流、輸入流
finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
return result;
}
=====調用很簡單======
String html;
try {
html = this.sendPost(“http:// localhost:8080/index”, “username=qiyipassword=123123” );
} catch (IOException e1) {
// TODO Auto-generated catch block
throw new RuntimeException(e1);
}
java中能不能使任何瀏覽器都能調用ie瀏覽器的打印功能
導入jquery的遷移插件jquery-migrate,打印插件jquery.jqprint.js,在IE裏面調用IE自帶的
javascript
的print方法,chrome裏面的調用插件的方法,在頁面引用一下IE的打印組件
就是下面這個,放在網頁裏面
如何用java調用IE打開本地網頁文件
用java runtime執行瀏覽器exe參數百度搜索頁面帶搜索關鍵字
代碼如下:
Runtime.getRuntime().exec(“C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe 呵呵”);
原創文章,作者:TNENP,如若轉載,請註明出處:https://www.506064.com/zh-hk/n/129866.html