servlet页面跳转

来源:百度知道 编辑:UC知道 时间:2024/05/10 12:54:59
package com.j.ch02;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Helloservlet extends HttpServlet {

/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

r

if (userName == "a" && userPass == "a") {
改为
if (userName .equals("a") && userPass.equals("a")) {
怎么感觉答过了!!

这里没有问题,检查下表单的NAME属性,如果没问题在检查web。xml。

if (userName == "a" && userPass == "a") {
改为
if (userName .equals("a") && userPass.equals("a")) {
怎么感觉答过了!!

应该是这个问题,楼上说的没错!

-----------------------------------------------------------
www.85buy.cn 你我商城,手机电池之家

userName=="a" 比较的是地址
userName.Equals("a") 是比较值的

用userNameEquals("a")才是正确的