jsp为什么得不到servlet传来的参数

来源:互联网 发布:mac os x lion 最新版 编辑:程序博客网 时间:2024/04/29 07:03
刚学jsp,做一个简单的登录界面,可是jsp得到的参数却一直是空,
在servlet中我写的是request.setAttribute("username", "coco");
在jsp中
<%
String str1 = (String)request.getAttribute("username");
%>
<%="用户名为:"%>
由于用request.getRequestDispatcher("/login.jsp ").forward(request, response);总显示404错误,所以我就直接在form中调用jsp    ,out.print("<form method=post action=login.jsp >");     
请各位大神帮忙看看哪里错了。