function js_method(){
window.open("http://localhost:1234/test/user/mylogin?login=test");
}
<a src="" href="javascript:void(0);" onclick="js_method()">登录</ a>
private void mylogin() throws Exception {
HttpSession session = request.getSession(true);
response.setHeader("Access-Control-Allow-Origin", "*");
String username = request.getParameter("login");
//1. 检查用户是否存在
session.setAttribute(OnlineUser.class.getSimpleName(), onlineUser);
response.sendRedirect("/test/page/system/main.html?" + new Date().getTime());
}
在IE浏览器下Session会丢失,需要用另外一个方法
function js_method2(urlstr){
var openobj = window;
if(typeof(window.dialogArguments) == 'object')
{
openobj = window.dialogArguments;
}
openobj.open(urlstr,"_blank");
}
<a href="#" onClick="js_method2('http://localhost:1234/test/user/mylogin?login=test')" >登录</a>