JSP±Ê¼Ç
JSPÔªËØ°üÀ¨£º1¡¢½Å±¾ÔªËØ£¨ÓïÑÔΪJava£¬Ê¹ÓÃJava´úÂë¹æ·¶¡£ÆäÖÐ<%!ÉùÃ÷£¨±äÁ¿¡¢·½·¨£©%><%=±í´ïÊ½ÔªËØ%><%³ÌÐò´úÂë%>£©
2¡¢Ö¸ÁîÔªËØ£ºÖ¸¶¨ÍøÒ³ÖеÄÖ¸ÁîÈçºÎ±»Ö´ÐУ¬°üÀ¨pageºÍinclude¡£
3¡¢¶¯×÷ÔªËØ£ºÁ¬½ÓÒªÓõÄ×é¼þ£¬ÈçJavaBean(useBean¡¢get/setProperty£©£¬»¹ÓÐparam¡¢forward¡¢include¡£
includeÖ¸ÁîÔªËØÊµÔÚ½«JSPתÒë³ÉServletʱ£¬²åÈëÁíÒ»ÎļþµÄÄÚÈÝ£¬ËùÒÔµ±ÁíÒ»ÎļþÖеÄÄÚÈݸıäʱ£¬²»»á·´Ó³µ±Ç°ÍøÒ³¡£¶øinclude¶¯×÷ÔªËØÊµÔÚ½øÐÐÒ³ÃæÇëÇóʱ£¬²åÈëÁíÒ»ÎļþÖеÄÄÚÈÝ£¬ËùÒÔµ±ÁíÒ»ÎļþÖеÄÄÚÈݸıäʱ£¬»á·´Ó³µ½µ±Ç°ÍøÒ³¡£Ç°ÕßΪ¾²Ì¬¼ÓÔØ£¬ºóÕßΪ¶¯Ì¬¼ÓÔØ¡£
Ïà¹ØÎĵµ£º
¿ª·¢Ó¦ÓóÌÐò¹ý³ÌÖеÄģʽ¸ÅÄGOFÊÇÃæÏò¶ÔÏóÈí¼þģʽµÄȨÍþ£¬Ëü½«ÃæÏò¶ÔÏóµÄÉè¼ÆÄ£Ê½·ÖΪÈýÖÖ»ù±¾ÀàÐÍ£º´´½¨Ä£Ê½£¬½á¹¹Ä£Ê½ºÍÐÐΪģʽ¡£
²ÉÓÃJSP¿ª·¢ÍøÕ¾µÄÈýÖÖģʽ£º
1.Ö±½ÓʹÓÃJSP
¿ª·¢Ð¡ÐÍÍøÕ¾£¬ÔÚJSPÒ³ÃæÖлìºÏHTMLºÍJava´úÂ룬ʹӦÓóÌÐòÄÑÒÔά»¤ºÍÀ©Õ¹;
2.ʹÓÃJSP+JavaBean
ÔÚҳà ......
Properties properties = new Properties();
File file = new File(request.getRealPath("/") +"\\WEB-INF\\classes\\configs.properties");
FileInputStream fiStream = new FileInputStream(file);
InputStreamRe ......
jsp:setProperty±êÇ©ÓÃÓÚÉèÖñ»¼ÓÔØµ½µ±Ç°Ò³ÃæÖеÄJavaBeanÖÐÊôÐÔµÄÖµ
¸ñʽ£º<jsp:setProperty name=? property=? value=?(»òparam=?) />
name£ºÄ³¸öJavaBeanµÄ¶ÔÏóÃû£¬ÓÃÓÚÖ¸¶¨¸øÄĸöJavaBeanÖеÄÊôÐÔ¸³Öµ
property£ºJavaBeanÖеÄij¸öÊôÐÔÃû£¬ÓÃÓÚÖ¸¶¨¸øµ±Ç°JavaBeanÖеÄÄĸöÊôÐÔ¸³Öµ
& ......
<%
//header.jsp
out.println("Protocol: " + request.getProtocol() + "<br>");
out.println("Scheme: " + request.getScheme() + "<br>");
out.println("Server Name: " + request.getServerName() + "<br>" );
out.println(&quo ......
½â¾ö·½·¨£º
µÚÒ»ÖÖ£ºÔÚActionÖÐÓà new String(str.getBytes("ISO8859_1"), "UTF8")£¬½øÐÐתÂ룬ÒòΪ´«µÝµÄʱºò£¬ÖÐÎÄĬÈ˵ÄÊÇISO8859_1
µÚ¶þÖÖ£º¿Éͨ¹ýÅäÖÃTOMCATÀ´½â¾ö´ËÎÊÌ⣬¾ßÌå½â¾ö·½·¨ÈçÏ£ºÔÚtomcatµÄserver.xmlÀÕÒµ½<Connector port="8080" useBodyEncodingForURI="true" URIEncoding="utf-8"> ......