·ÃÎÊJSPÎļþ»òÕßServletÎļþʱÌáʾ¡°ÏÂÔØ¡±
ÔÚ·ÃÎÊJSPÎļþ»òÕßServletµÄʱºò£¬Èç¹ûÌáʾÏÂÔز¢±£´æ£¬ÈçÏÂͼËùʾ£º
ͬÑùµÄ³ÌÐòÓеÄä¯ÀÀÆ÷³ö´í£¬ÓеÄä¯ÀÀÆ÷²»³ö´í¡£´íÎóµÄÔÒòÊÇÉèÖÃMIMEÀàÐ͵ĴúÂëÓÐÎó¡£
Èç¹ûÊÇJSPÎļþ£¬²é¿´ÎļþÍ·£º
<%@ page contentType="text/html;charset=gb2312"%>
Èç¹ûÊÇServletÎļþ£¬²é¿´£º
response.setContentType("text/html;charset=gb2312");
Ïà¹ØÎĵµ£º
JSPÒ³ÃæÌøת´óÈ«
JSPÖеÄÌøת£º
(1). forward()·½·¨
ʹÓõ½javax.servlet.RequestDispatcherÀà
RequestDispatcher rd = getServletContext().getRequestDispatcher("url");
rd.forward(requestVar,requestVar); //´«µÝservletµÄÈë¿Ú²ÎÊý
......
½¨Á¢Ìõ¼þÊ×ÏÈÒ»¶¨ÒªÈ·¶¨×Ô¼ºµÄmysql£¬tomcat,eclipseÁ¬½ÓÊÇÕýÈ·µÄ¡£
index.jspºÜ¼òµ¥£¬¾ÍÒ»¸öÌøת¡£
<%
response.sendRedirect("lg.jsp");
%>
lg.jsp ʵÏֵǼ¿ò¼Ü
<%@ page contentType="text/html; charset=utf-8" %>
<html>
<head>
<title>
login
</title>
</hea ......
·½·¨Ò»¡¢
login.html
<html>
<head>
<title>Óû§µÇ¼</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
</head>
<script language="javascript">
&nbs ......
1.±ØÐë¼Ì³Ð×ÔHttpServlet
2.±ØÐëʵÏÖdoGet()»òÕßdoPost()
3.±ØÐëÔÚweb.xmlÖÐÅäÖÃServlet
<servlet>
<servlet-name> </servlet-name>
<servlet-class> </servlet-class>
</servlet>
<servlet-mapping>
......
jspÖеÚÒ»¾ä£º
<%@ page language="java" import="java.sql.*,java.util.*," contentType="text/HTML;charset=gb2312" pageEncoding="gb2312"%>
htmlÖмÓÉÏ
<meta http-equiv="Content-Type" content="text/html;charset=gb2312" />
ͨ³£ÕâÑù¾ÍûÓÐÎÊÌâÁË¡£ .
ÔÙÕߣº µ¼ÈëjsʱºòÉ ......