怎么从jsp页面跳转到html页面

来源:百度知道 编辑:UC知道 时间:2024/06/17 08:37:44
我有一个logon.jsp登陆页面,有一个main.html页面,现在要登陆成功后跳到main.html页面,怎么用<jsp:forward>不能跳转。
connect con=new connect();
con.conn();
ResultSet rss=null;

boolean a=false;

String uid=request.getParameter("uid");
String pwd=request.getParameter("pwd");
System.out.println(uid);
System.out.println(pwd);

String sql="select * from Account where AccountId='"+uid+"' and password='"+pwd+"' ";
rss=con.executeQuery(sql);
try
{
if(rss.next())
{
a=true;
}
}
catch (SQLException e) {
e.printStackTrace();
}
System.out.println(a);
if(a==true)
{
%>
<jsp:forward page="frameset/main.html"><

用response.sendRedirect("frameset/main.html");

写法有问题。
<jsp:forward page="xxx/xxx.jsp">forward动作对应的是Servlet中RequestDispatcher类的forward(ServletRequest request, ServletResponse response)方法,也就是把请求进行转发。
也可以写成
<jsp:forward>
<jsp:attribute name="page">xxx/xxx.jsp</jsp:attribute>
</jsp:forward>
这种写法等价于上面的写法。

request.getRequestDispatcher("url").forward(request,response);也可以

改成jsp不就行了,又不影响

登陆跳转不宜用<jsp:forward>
应该用redirect

贴出代码看看