高分求助一个关于“URL重写”的问题!!!谢谢指点! ' "+response.encodeURL("Step2")+"'仔细看看,多了一个空格啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可能是step2位置中指向的servlet没定义post方法 检查了半天还是没搞定,我把源码贴上来大家帮忙看一下:(STEP1。JAVAimport java.io.*;import java.util.*;import javax.servlet.*;import javax.servlet.http.*;public class Step1 extends HttpServlet{ public Step1() { } public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { HttpSession session = request.getSession(); displayPage(request, response); } public void displayPage(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html;charset=gb2312"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<head>"); out.println("<title>Step 1:选择要购买的书籍</title>"); out.println("</head>"); out.println( "<meta http-equiv=Content-Type content=text/html;charset=GB2312>"); out.println("<body>"); out.println("<b><font size=4>Step 1:选择要购买的书籍</font></b>"); out.println("<form action='"+response.encodeURL("Step2")+"' method='POST'>"); out.println("<table border=1 width=80%>"); out.println("<tr>"); out.println("<td align=center bgcolor=#008080>"); out.println("<font color=#ffffff>书名</font>"); out.println("</td>"); out.println("<td align=center bgcolor=#008080>"); out.println("<font color=#ffffff>购买</font>"); out.println("</td>"); out.println("</tr>");。以下HTML代码略。STEP2。JAVAimport java.io.*;import java.util.*;import javax.servlet.*;import javax.servlet.http.*;public class Step2 extends HttpServlet{ public Step2() { } public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { processStep1(request, response); displayPage(request, response); } public void processStep1(HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(); String b[] = request.getParameterValues("buy"); books booksWanted = new books(b); session.setAttribute("A_booksWanted", booksWanted); } public void displayPage(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html;charset=gb2312"); PrintWriter out = response.getWriter(); out.println(" <title>Step 2:输入寄送地址与信用卡信息</title>"); out.println( " <meta http-equiv=content-type content=text/html;charset=gb2312>"); out.println(" <style type=text/css>"); out.println(" <!--"); out.println(" .style1 {color: #FFFFFF}"); out.println(" -->"); out.println(" </style>"); out.println(" <p>Step 2:输入寄送地址与信用卡信息</p>"); out.println(" <form name=form1 method=post action="+response.encodeURL("Confirm2")+">"); out.println(" <table width=80% border=1>"); out.println(" <tr bgcolor=#008080>"); out.println(" <td colspan=2><span class=style1>基本信息</span></td>"); out.println(" </tr>");以下HTML代码略。CONFIRM2。JAVA:public class Confirm2 extends HttpServlet{ public Confirm2() { } public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { processStep2(request, response); displayPage(request, response); } public void processStep2(HttpServletRequest request, HttpServletResponse response) throws IOException { HttpSession session = request.getSession(true); String customername = new String(request.getParameter("customername"). getBytes("iso-8859-1")); //byte[] java.lang.String.getBytes(String charsetName);以getBytes("iso-8859-1")方法取出以避免中文字的转码问题 String address = new String(request.getParameter("address").getBytes( "iso-8859-1")); String credittype = request.getParameter("credittype"); String expiredate = request.getParameter("expiredate"); String creditno = request.getParameter("creditno"); session.setAttribute("A_customername", customername); session.setAttribute("A_address", address); session.setAttribute("A_credittype", credittype); session.setAttribute("A_expiredate", expiredate); session.setAttribute("A_creditno", creditno); } public void displayPage(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html;charset=gb2312"); PrintWriter out = response.getWriter(); HttpSession session = request.getSession(true); books booksWanted = (books) session.getAttribute("A_booksWanted"); String customername = (String) session.getAttribute("A_customername"); String address = (String) session.getAttribute("A_address"); String credittype = (String) session.getAttribute("A_credittype"); String creditno = (String) session.getAttribute("A_creditno"); String expiredate = (String) session.getAttribute("A_expiredate");。谢谢各位~ 搞定了。原来out.println(" <form name=form1 method=post action="+response.encodeURL("Confirm2")+">");这句要加两个单引号。= =bSERVLET和JSP不像ASP那样可以把所有的引号都去掉啊~~~ 在MyEclipse中能运行的jQuery到Eclipse中不能运行。(拿分走人啦) 求大神,求解释 spring如何代替hibernate hibernate连oracle 10g报错 急!!!Remote Back-up System Using Web Services 学习J2EE之前是不是非要把J2SE的基础打好? hibernate中映射出错。 向主窗口传送值没有反应,怎么回事? sessionbean中调用本地entitybean的问题 关于Applet的图形处理后,如何保存?急急! 卖摩托车的程序员,超低价!吐血价,不容错过!附:心痛的卖车理由! 求一基础sql语句
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;public class Step1 extends HttpServlet
{
public Step1()
{
} public void doGet(HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException
{
HttpSession session = request.getSession();
displayPage(request, response);
} public void displayPage(HttpServletRequest request,
HttpServletResponse response) throws IOException
{
response.setContentType("text/html;charset=gb2312");
PrintWriter out = response.getWriter(); out.println("<html>");
out.println("<head>");
out.println("<title>Step 1:选择要购买的书籍</title>");
out.println("</head>");
out.println(
"<meta http-equiv=Content-Type content=text/html;charset=GB2312>");
out.println("<body>");
out.println("<b><font size=4>Step 1:选择要购买的书籍</font></b>"); out.println("<form action='"+response.encodeURL("Step2")+"' method='POST'>");
out.println("<table border=1 width=80%>");
out.println("<tr>");
out.println("<td align=center bgcolor=#008080>");
out.println("<font color=#ffffff>书名</font>");
out.println("</td>");
out.println("<td align=center bgcolor=#008080>");
out.println("<font color=#ffffff>购买</font>");
out.println("</td>");
out.println("</tr>");。以下HTML代码略。STEP2。JAVA
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;public class Step2 extends HttpServlet
{
public Step2()
{
} public void doPost(HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException
{
processStep1(request, response);
displayPage(request, response);
} public void processStep1(HttpServletRequest request,
HttpServletResponse response)
{
HttpSession session = request.getSession();
String b[] = request.getParameterValues("buy");
books booksWanted = new books(b);
session.setAttribute("A_booksWanted", booksWanted);
} public void displayPage(HttpServletRequest request,
HttpServletResponse response) throws IOException
{
response.setContentType("text/html;charset=gb2312");
PrintWriter out = response.getWriter(); out.println(" <title>Step 2:输入寄送地址与信用卡信息</title>");
out.println(
" <meta http-equiv=content-type content=text/html;charset=gb2312>");
out.println(" <style type=text/css>");
out.println(" <!--");
out.println(" .style1 {color: #FFFFFF}");
out.println(" -->");
out.println(" </style>"); out.println(" <p>Step 2:输入寄送地址与信用卡信息</p>");
out.println(" <form name=form1 method=post action="+response.encodeURL("Confirm2")+">");
out.println(" <table width=80% border=1>");
out.println(" <tr bgcolor=#008080>");
out.println(" <td colspan=2><span class=style1>基本信息</span></td>");
out.println(" </tr>");
以下HTML代码略。CONFIRM2。JAVA:public class Confirm2 extends HttpServlet
{
public Confirm2()
{
} public void doPost(HttpServletRequest request, HttpServletResponse response) throws
IOException, ServletException
{
processStep2(request, response);
displayPage(request, response);
} public void processStep2(HttpServletRequest request,
HttpServletResponse response) throws IOException
{
HttpSession session = request.getSession(true);
String customername = new String(request.getParameter("customername").
getBytes("iso-8859-1"));
//byte[] java.lang.String.getBytes(String charsetName);以getBytes("iso-8859-1")方法取出以避免中文字的转码问题
String address = new String(request.getParameter("address").getBytes(
"iso-8859-1"));
String credittype = request.getParameter("credittype");
String expiredate = request.getParameter("expiredate");
String creditno = request.getParameter("creditno"); session.setAttribute("A_customername", customername);
session.setAttribute("A_address", address);
session.setAttribute("A_credittype", credittype);
session.setAttribute("A_expiredate", expiredate);
session.setAttribute("A_creditno", creditno); } public void displayPage(HttpServletRequest request,
HttpServletResponse response) throws IOException
{
response.setContentType("text/html;charset=gb2312");
PrintWriter out = response.getWriter();
HttpSession session = request.getSession(true); books booksWanted = (books) session.getAttribute("A_booksWanted");
String customername = (String) session.getAttribute("A_customername");
String address = (String) session.getAttribute("A_address");
String credittype = (String) session.getAttribute("A_credittype");
String creditno = (String) session.getAttribute("A_creditno");
String expiredate = (String) session.getAttribute("A_expiredate");。谢谢各位~
SERVLET和JSP不像ASP那样可以把所有的引号都去掉啊~~~