Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JSPÌøתµÄ¼¸ÖÖ·½Ê½|Struts¶¯Ì¬Ìøת

String url="http://www.baidu.com";
   ActionForward gotourl = new ActionForward(url);
   gotourl.setPath(url);
   gotourl.setRedirect(true);
   return gotourl;
  1.RequestDispatcher.forward()
¡¡¡¡ ÊÇÔÚ·þÎñÆ÷¶ËÆð×÷ÓÃ,µ±Ê¹ÓÃforward()ʱ,Servlet engine´«µÝHTTPÇëÇó´Óµ±Ç°µÄServlet or JSPµ½ÁíÍâÒ»¸öServlet,JSP »òÆÕͨHTMLÎļþ,Ò²¼´ÄãµÄformÌá½»ÖÁa.jsp,ÔÚa.jspÓõ½ÁËforward()Öض¨ÏòÖÁb.jsp,´ËʱformÌá½»µÄËùÓÐÐÅÏ¢ÔÚ b.jsp¶¼¿ÉÒÔ»ñµÃ,²ÎÊý×Ô¶¯´«µÝ.
¡¡¡¡µ«forward()ÎÞ·¨Öض¨ÏòÖÁÓÐframeµÄjspÎļþ,¿ÉÒÔÖض¨ÏòÖÁÓÐframeµÄhtmlÎļþ,ͬʱforward()ÎÞ·¨ÔÚºóÃæ´ø²ÎÊý´«µÝ,±ÈÈçservlet?name=frank,ÕâÑù²»ÐÐ,¿ÉÒÔ³ÌÐòÄÚͨ¹ýresponse.setAttribute("name",name)À´´«ÖÁÏÂÒ»¸öÒ³Ãæ.
¡¡¡¡Öض¨Ïòºóä¯ÀÀÆ÷µØÖ·À¸URL²»±ä.
¡¡¡¡Àý:ÔÚservletÖнøÐÐÖض¨Ïò
 
Java´úÂë
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException   
{   
¡¡ response.setContentType("text/html; charset=gb2312");   
¡¡ ServletContext sc = getServletContext();   
¡¡ RequestDispatcher rd = null;   
¡¡ rd = sc.getRequestDispatcher("/index.jsp"); //¶¨ÏòµÄÒ³Ãæ   
¡¡ rd.forward(request, response);   
}  
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
{
¡¡ response.setContentType("text/html; charset=gb2312");
¡¡ ServletContext sc = getServletContext();
¡¡ RequestDispatcher rd = null;
¡¡ rd = sc.getRequestDispatcher("/index.jsp"); //¶¨ÏòµÄÒ³Ãæ
¡¡ rd.forward(request, response);
}
 
¡¡¡¡Í¨³£ÔÚservletÖÐʹÓ㬲»ÔÚjspÖÐʹÓá£
 
       2.response.sendRedirect()
¡¡¡¡ÊÇÔÚÓû§µÄä¯ÀÀÆ÷¶Ë¹¤×÷,sendRedirect()¿ÉÒÔ´ø²ÎÊý´«µÝ,±ÈÈçservlet?name=frank´«ÖÁϸöÒ³Ãæ,ͬʱËü¿ÉÒÔÖض¨ÏòÖÁ²»Í¬µÄÖ÷»úÉÏ,sendRedirect()¿ÉÒÔÖض¨ÏòÓÐframe.µÄjspÎļþ.
¡¡¡¡Öض¨ÏòºóÔÚä¯ÀÀÆ÷µØ


Ïà¹ØÎĵµ£º

ÕÐƸjsp\phpÍøÕ¾¿ª·¢³ÌÐòÔ±

ÉϺ£ÔóÎäÍøÂçÓÐÏÞ¹«Ë¾
ÕÐƸ£ºÕÐƸjsp\phpÍøÕ¾¿ª·¢³ÌÐòÔ±
ÒªÇóÓÐÈýÄêÒÔÉÏ¿ª·¢¾­Ñé
¶ÔTomcat+Apache¼¯Èº¼¼ÊõÓÐÊìϤµÄ¾­Ñé.¶ÔËÑË÷ÒýÇæ¼¼Êõ(Lucene)±È½ÏÁ˽⡣
-ÊìÁ·Ê¹ÓÃUML½¨Ä£¹¤¾ß¡¢°æ±¾¿ØÖƹ¤¾ß; ÊìÁ·Ê¹ÓÃEclipseµÈIDE¿ª·¢¹¤¾ß;
-¾«Í¨JAVA,php,ÉîÈëÀí½âOOP˼Ïë,ÊìϤÉè¼Æģʽ¡£
-ÊìÁ·ÔËÓÃJ2EE¼¼Êõ¡¢WEB·þÎñÆ÷ºÍ¹ØϵР......

jspÂÒÂë½â¾ö´óÈ«(ת×ÔcsdnÒ»¸ßÊÖ)

jspÖÐÎÄÏÔʾÂÒÂë½â¾ö·½°¸
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
¶þ¡¢±íµ¥Ìá½»ÖÐÎÄʱ³öÏÖÂÒÂë
Èý¡¢Êý¾Ý¿âÁ¬½Ó
´ó¼ÒÔÚJSPµÄ¿ª·¢¹ý³ÌÖУ¬¾­³£³öÏÖÖÐÎÄÂÒÂëµÄÎÊÌ⣬¿ÉÄÜÒ»ÖÁÀ§ÈÅ×ÅÄú£¬ÎÒÏÖÔÚ°ÑÎÒÔÚJSP¿ª·¢ÖÐÓöµ½
µÄÖÐÎÄÂÒÂëµÄÎÊÌâ¼°½â¾ö°ì·¨Ð´³öÀ´¹©´ó¼Ò²Î¿¼¡£
Ò»¡¢JSPÒ³ÃæÏÔʾÂÒÂë
ÏÂÃæµÄÏÔʾҳÃæ(display.jsp)¾Í³öÏÖÂÒÂ룺
< ......

×éÆ´jsp·½·¨

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> ......

jsp visit spring


<%@page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="ccp.suddenattack.service.news.*"%> ......

jspµ¯³öд°¿Ú´úÂë

¸÷ÀàÍøÒ³µ¯´°´úÂë±àд
¡¡
¾­³£ÉÏÍøµÄÅóÓÑ¿ÉÄܻᵽ¹ýÕâÑùһЩÍøÕ¾£¬Ò»½øÈëÊ×Ò³Á¢¿Ì»áµ¯³öÒ»¸ö´°¿Ú£¬»òÕß°´Ò»¸öÁ¬½Ó»ò°´Å¥µ¯³ö£¬Í¨³£ÔÚÕâ¸ö´°¿ÚÀï»áÏÔʾһЩעÒâÊÂÏî¡¢°æȨÐÅÏ¢¡¢¾¯
¸æ¡¢»¶Ó­¹â¹ËÖ®ÀàµÄ»°»òÕß×÷ÕßÏëÒªÌرðÌáʾµÄÐÅÏ¢¡£ÆäʵÖÆ×÷ÕâÑùµÄÒ³ÃæЧ¹û·Ç³£µÄÈÝÒ×£¬Ö»ÒªÍù¸ÃÒ³ÃæµÄHTMLÀï¼ÓÈ뼸¶ÎJavascript´úÂë¼´¿ÉÊ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ