无法在Servlet中解析参数 [英] Parameters cannot be resolved in servlets

查看:104
本文介绍了无法在Servlet中解析参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从jsp page-index.jsp获取凭证 在我的servlet-LoginServlet中,当使用dao软件包时,使用

I am tryin to get the credentials from jsp page-index.jsp In my servlet-LoginServletwhen under package dao i use

String userName = request.getParameter(usrnm_gtalk);
String password = request.getParameter(password_gtalk);

usrnm_gtalkpassword_gtalk无法解析.

在我的jsp中

<form name="LoginForm" method="post" action="/dao/LoginServlet>   
<input type="text" name="usrnm_gtalk"/>
<input type="password" name="password_gtalk" />

web.xml

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description></description>
    <display-name>LoginServlet</display-name>
    <servlet-name>LoginServlet</servlet-name>
    <servlet-class>dao.LoginServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>LoginServlet</servlet-name>
    <url-pattern>/Login</url-pattern>
  </servlet-mapping>

我在库中有servlet-api jar以及构建路径

i have the servlet-api jar in the lib as well as build path

谁能指出point是问题所在 谢谢

can anyone point out wat is the problem Thanks

推荐答案

您需要将它们表示为带双引号的字符串,而不是不存在的变量(因为编译器试图告诉您).

You need to represent them as strings, with doublequotes, not as non-existing variables (as the compiler is trying to tell you).

String userName = request.getParameter("usrnm_gtalk"); 
String password = request.getParameter("password_gtalk");

另请参见:

  • Java教程-字符串
  • "Servlet信息"页面-包含一个小小的问候世界
  • See also:

    • The Java Tutorials - Strings
    • Servlets info page - contains a little hello world
    • 这篇关于无法在Servlet中解析参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆