login.jsp<%@ page language="java" import="java.util.List" pageEncoding="gbk"%><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>管理平台</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
overflow:hidden;
}
.STYLE3 {color: #528311; font-size: 12px; }
.STYLE4 {
color: #42870a;
font-size: 12px;
}
-->
</style></head><body>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#e5f6cf">&nbsp;</td>
  </tr>
  <tr>
    <td height="608" background="images/login_03.gif"><table width="862" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="266" background="images/login_04.gif">&nbsp;</td>
      </tr>
      <tr>
        <td height="95"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="424" height="95" background="images/login_06.gif">&nbsp;</td>
            <td width="183" background="images/login_07.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="21%" height="30"><div align="center"><span class="STYLE3">用户</span></div></td>
                <td width="79%" height="30">
                <input type="text" name="username" id="username" style="height:18px; width:130px; border:solid 1px #cadcb2; font-size:12px; color:#81b432;">
                </td>
              </tr>
              <tr>
                <td height="30"><div align="center"><span class="STYLE3">密码</span></div></td>
                <td height="30">
                <input type="password" name="password" id="password" style="height:18px; width:130px; border:solid 1px #cadcb2; font-size:12px; color:#81b432;">
                </td>
              </tr>
              <tr>
                <td height="30">&nbsp;</td>
                <td height="30"><img src="images/dl.gif" width="81" height="22" border="0" usemap="Map"></td>
              </tr>
            </table></td>
            <td width="255" background="images/login_08.gif">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td height="247" valign="top" background="images/login_09.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="22%" height="30">&nbsp;</td>
            <td width="56%">&nbsp;</td>
            <td width="22%">&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="44%" height="20">&nbsp;</td>
                <td width="56%" class="STYLE4">版本 2010V1.0 </td>
              </tr>
            </table></td>
            <td>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td bgcolor="#a2d962">&nbsp;</td>
  </tr>
</table><map name="Map"><area shape="rect1" coords="3,3,36,19" href="login_System.action"><area shape="rect" coords="40,3,78,18" href="#"></map></body>
</html>Action:
HttpServletRequest request = ServletActionContext.getRequest();
String username = request.getParameter("username");    
String password = request.getParameter("password");都执行了login_System.action,就是获取不到用户和密码的值?郁闷

解决方案 »

  1.   

    都执行了login_System.action,就是在action里获取不到用户和密码的值
      

  2.   

    action  ?
    用的是struts ?
    既然是struts 你为何还要用
    String username = request.getParameter("username");                   
    String password = request.getParameter("password");
    ??
    用getter setter方法好一点吧?
    我也没看到你的form  不知道你是怎么提交到那个action的。
      

  3.   


    struts2 
    HttpServletRequest request = ServletActionContext.getRequest();获取到request
    在jsp页面有问题 总是获取不到。 
      

  4.   

    structs会重新封装HttpServletRequest,你这样ServletActionContext.getRequest()是不能取到struts的request里面的值的
      

  5.   

    加个form
    <area shape="rect1" coords="3,3,36,19" onclick="subMit()">
    function subMit(){
    var username = document.getElementById('username');
    var password = document.getElementById('password');
    var url = "xx.action&username="+username + "&password=" + password;
    document.forms[0].action=url;
    document.forms[0].submit();
    }
      

  6.   

    没有写form吧。没有写form是提交不到的。
    还有这个ServletActionContext.getRequest()获取到的request是不是空的呢?
      

  7.   

    <tr>
          <td height="30">&nbsp;</td>
          <td height="30"><img src="images/dl.gif" width="81" height="22" border="0" usemap="Map"></td>
    </tr><map name="Map"><area shape="rect1" coords="3,3,36,19" href="login_System.action"><area shape="rect" coords="40,3,78,18" href="#">
    </map>代码关键在这里,因此我不知道该怎么提前用户和密码值
      

  8.   

    你可以这么获取request试试。
    public class myAction extend ActionSupport implemts ServletRequestAware{    private HttpServletRequest request;    public void setServletRequest(HttpServletRequest request) {
    this.request = request;
    }
    }用这个方法换掉你的request试试
      

  9.   

    你在<body></body>前后加一个<form></form>。
    <body><form> .......其他代码</form></body>
    试试。
      

  10.   

    你的这个路径写在这里,当然action里取不到值了。要不用form表单来指定跳转路径,要不就是用超链接来指定。你现在用的超链接来指定,必须写成这个样子:login_System.action?userName=xxx&password=xxx
      

  11.   


    在struts2里可以这样得到request :HttpServletRequest request = ServletActionContext.getRequest();
    我重新做了一个login.jsp 都可以获取到值。
    所以我觉得这事html map标签的事情 导致我不能获取到值
      

  12.   

    我也没看到你的form 不知道你是怎么提交到那个action的。
      

  13.   


    map标准这里 我要是修改为onclick的话 点击不了
      

  14.   

    那就把MAp去掉直接在登陆图片上用onclick
      

  15.   

    如果使用的是Struts2,在要获取值的Input标签中的name属性为"user.username",并且在Action中写User的getter和setter方法,取值的时候用对象点出来!
      

  16.   

    <script type="text/javascript">
       function mysubmit(){}
    </script><map name="Map"><area shape="rect1" coords="3,3,36,19" href="login_System.action"><area shape="rect" coords="40,3,78,18" href="#"></map></
      

  17.   

    <script   type= "text/javascript "> 
          function   mysubmit(){ 
          var username=Document.getElementById("username").value;
          var password=Document.getElementById("password").value;
          window.location="login_System.action?username="+username+"&password"+password;

    </script> <map name= "Map "> <area   shape= "rect1 "   coords= "3,3,36,19 "   href= "#" 
    onclick="mysubmit();"> <area   shape= "rect "   coords= "40,3,78,18 "   href= "# "> </map>
    我想只能用js来解决了。
      

  18.   

    area标签里加这个试试nohref="false"
      

  19.   

    虽然没有学习过struts2.但是我觉得你不管用1或者2,甚至是servlet你最好也把要提交的表单装进form里。
      

  20.   

    最好使用的是form中去。要不就是要使用的js的进行值得提取,然后使用js进行登录提取呀!
      

  21.   

    form都没有,哪里来的值提交,你用的<map><area>标记,当点击到改区域里面后就会根据src的设置的路径去调用action,建议用form