日期:2014-05-17  浏览次数:20787 次

jsp到serlet传值的问题
本帖最后由 fatso1984 于 2013-08-09 16:21:53 编辑
jsp代码:

<form action="<%=path%>/Index">
  <c:set var="qqq" value="123" scope="page"></c:set>
     <%
     request.setAttribute("temp1","456") ;
     %>
   <input type="submit" value="111">
 </form>

servlet代码:

System.out.println(request.getAttribute("qqq"));
System.out.println(request.getAttribute("temp1"));

打出来的值都是null,jsp无法向serlvet中传值吗???

------解决方案--------------------
login.jsp

<form method="post" name="unform" action="<%=basePath%>LoginServlet" target="_parent">
<table border="0" width="61%" style="background-color:#888fff" bgcolor="#888fff" > 
 
 
<td width="80%" class="3dfont"><font color="#008040"></font>
 
  
<table border="0" width="100%"  bgcolor="#888fff" > 
    <input type="hidden"  id="info" value="${param.info}">
   <tr >
   <td width="10%" class="3dfont"><b>账户</b></td>
   <td width="20%"><input type="text" name="username"  value="bcsflilong"/></td>
   <td width="10%" class="3dfont"><b>密码</b></td>
   <td width="20%"><input type="password" name="psw"  value="" /></td>
   <td width="20%"><input type="submit" onClick="return _submit()" value="登录"> </td>
   </tr></b>
    
</table></td></table></center>
</form>

LoginServlet

public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletExceptionIOException {