同一 HTML 页面中的 Jsp 和 Servlet
•浏览 1
Jsp and Servlets in same HTML page
我想开发一个包含注册和登录按钮的登录 HTML 页面。在运行时的 HTML 页面中,我可以选择任何按钮(登录/注册)。单击注册时,页面应重定向到 Signup JSP 程序,单击登录页面时,页面应重定向到登录 Servlet 程序。现在的问题是我必须在html页面中的表单操作方法中提到哪个页面(JSP/SERVLET)。 ?如何解决这个问题?
你可以插入文本
示例:
Sign In
Sign Up<!--sign in button code -->
<!--sign up button code --><html>
<head>
function open_win()
{
window.open("http://yoururl.com");
/*or
window.location.href="/yourpathToPageOrServletIfany/yourfiel.jsp.html.phpOrYourServletMapping";
*/
}
</head>
<body>
<input type="button" value="Open Window" onclick="open_win()">
</body>
</html>
应该是简单的超链接[GET],不需要提交表单
Sign In
Sign Up<!--sign in button code -->
<!--sign up button code --><html>
<head>
function open_win()
{
window.open("http://yoururl.com");
/*or
window.location.href="/yourpathToPageOrServletIfany/yourfiel.jsp.html.phpOrYourServletMapping";
*/
}
</head>
<body>
<input type="button" value="Open Window" onclick="open_win()">
</body>
</html>
如果要使用按钮,则必须通过 jQuery 或 javascript 事件,例如按钮的 onClick。这是几个例子。正是你需要的。您不需要通过表单操作提交来做到这一点。
Sign In
Sign Up<!--sign in button code -->
<!--sign up button code --><html>
<head>
function open_win()
{
window.open("http://yoururl.com");
/*or
window.location.href="/yourpathToPageOrServletIfany/yourfiel.jsp.html.phpOrYourServletMapping";
*/
}
</head>
<body>
<input type="button" value="Open Window" onclick="open_win()">
</body>
</html>
同样的事情可以用 jquery $('#buttonId').click(function(){...in here ...});