java start the browser many ways, I am also referring to the summary of the god on the basis of you, want to help other students, thanks to big brother
https://blog.csdn.net/zp357252539/article/details/77896257/ , there is talk of launching a browser many ways, but the pass parameters to die,
try {
Runtime.getRuntime().exec( "cmd /c start http://localhost:8012/admin/sysAdminOfPlatform.do?sysId=141);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
This approach can only pass a parameter, controller background with String id = request.getParameter ( "sysId"); receiving, but then I found that you can pass multiple parameters-place, and start the default browser
try {
//http://localhost:8012
String serverName=request.getServerName();
int port=request.getServerPort();
String url = "http://"+serverName+":"+port+"/admin/sysAdminOfPlatform.do?sysId=141&uesrId=1681&memberid="+m.getId();
java.net.URI uri = java.net.URI.create(url);
// 获取当前系统桌面扩展
java.awt.Desktop dp = java.awt.Desktop.getDesktop();
// 判断系统桌面是否支持要执行的功能
if (dp.isSupported(java.awt.Desktop.Action.BROWSE)) {
dp.browse(uri);
// 获取系统默认浏览器打开链接
}
} catch (java.lang.NullPointerException e1) {
// 此为uri为空时抛出异常
e1.printStackTrace();
} catch (java.io.IOException e1) {
// 此为无法获取系统默认浏览器
e1.printStackTrace();
}
Eradicate address, a plurality of transmission parameters, the following background reception
Integer sysId=Integer.valueOf(request.getParameter("sysId"));
Integer userId=Integer.valueOf(request.getParameter("uesrId"));
Integer memberid=Integer.valueOf(request.getParameter("memberid"));
The perfect solution!