主题:[讨论]這兩段代碼有什麼不一樣嗎??急,在線等!!!謝謝!!
其他代碼都是一樣的!!就把這兩段代碼換下,
這兩段代碼好象都是一樣的,但是就是顯示的結果不一樣,
我鬱悶了,各位幫幫忙!!!!
這段代碼顯示出另一個修改的窗口,
public class EditServlet extends SessionCheckServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK";
public void doAction(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String strId = request.getParameter("id");
int id = Integer.parseInt(strId);
EditDao dao = new EditDao();
UseInfo info = null;
try {
info = dao.getUserById(id);
} catch (MyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>EditServlet</title></head>");
out.println("<body bgcolor=\"#ffffff\">");
out.println("<form action='update' method='post'>");
out.println(" <input type='hidden' name='id' value='" + info.id
+ "'/>");
out.println(" 姓名:<input type='text' name='name' value='" + info.name
+ "'/><br/>");
out.println(" 密碼:<input type='password' name='password' value='"
+ info.password + "'/><br/>");
out.println(" <input type='submit' value='提交'/>");
out.println("</form>");
out.println("</body>");
out.println("</html>");
out.close();
}
這段代碼卻彈出一個下載的框。
public class EditServlet extends SessionCheckServlet {
private static final String CONTENT_TYPE = "text/html,charset=GBK";
// @Override
public void doAction(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String strId = request.getParameter("id");
int id = Integer.parseInt(strId);
EditDao dao = new EditDao();
UseInfo info = null;
try {
info = dao.getUserById(id);
} catch (MyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println(" <head><title>EditServlet</title></head>");
out.println(" <body>");
out.println(" <form action='update' method='post'>");
out.println(" <input type='hidden' name='id' value='" + info.id
+ "'/>");
out.println(" 姓名:<input type='text' name='name' value='" + info.name
+ "'/><br/>");
out.println(" 密碼:<input type='password' name='password' value='"
+ info.password + "'/><br/>");
out.println(" <input type='submit' value='提交'/>");
out.println(" <input type='reset' value='取消'/>");
out.println(" </form>");
out.println(" </body>");
out.println("</html>");
out.close();
}
這兩段代碼好象都是一樣的,但是就是顯示的結果不一樣,
我鬱悶了,各位幫幫忙!!!!
這段代碼顯示出另一個修改的窗口,
public class EditServlet extends SessionCheckServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK";
public void doAction(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String strId = request.getParameter("id");
int id = Integer.parseInt(strId);
EditDao dao = new EditDao();
UseInfo info = null;
try {
info = dao.getUserById(id);
} catch (MyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>EditServlet</title></head>");
out.println("<body bgcolor=\"#ffffff\">");
out.println("<form action='update' method='post'>");
out.println(" <input type='hidden' name='id' value='" + info.id
+ "'/>");
out.println(" 姓名:<input type='text' name='name' value='" + info.name
+ "'/><br/>");
out.println(" 密碼:<input type='password' name='password' value='"
+ info.password + "'/><br/>");
out.println(" <input type='submit' value='提交'/>");
out.println("</form>");
out.println("</body>");
out.println("</html>");
out.close();
}
這段代碼卻彈出一個下載的框。
public class EditServlet extends SessionCheckServlet {
private static final String CONTENT_TYPE = "text/html,charset=GBK";
// @Override
public void doAction(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String strId = request.getParameter("id");
int id = Integer.parseInt(strId);
EditDao dao = new EditDao();
UseInfo info = null;
try {
info = dao.getUserById(id);
} catch (MyException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println(" <head><title>EditServlet</title></head>");
out.println(" <body>");
out.println(" <form action='update' method='post'>");
out.println(" <input type='hidden' name='id' value='" + info.id
+ "'/>");
out.println(" 姓名:<input type='text' name='name' value='" + info.name
+ "'/><br/>");
out.println(" 密碼:<input type='password' name='password' value='"
+ info.password + "'/><br/>");
out.println(" <input type='submit' value='提交'/>");
out.println(" <input type='reset' value='取消'/>");
out.println(" </form>");
out.println(" </body>");
out.println("</html>");
out.close();
}