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

½â¾öJSPÂÒÂëµÄ¹ýÂËÆ÷

----*web.xml *----
----*web.xml *----
  <filter>
    <filter-name>MyFilter</filter-name>
    <filter-class>cray.util.MyFilter</filter-class>
  </filter>
 
  <filter-mapping>
    <filter-name>MyFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
------------MyFilter.java-------------
import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import java.io.IOException;
public class MyFilter extends HttpServlet implements Filter
{
 private FilterConfig filterConfig;
 public void init(FilterConfig filterConfig) throws ServletException
 {
  this.filterConfig = filterConfig;
 }
 public void doFilter(ServletRequest request, ServletResponse response,
   FilterChain filterChain)
 {
  try
  {
   request.setCharacterEncoding("GBK");
   filterChain.doFilter(request, response);
  } catch (ServletException sx)
  {
   filterConfig.getServletContext().log(sx.getMessage());
  } catch (IOException iox)
  {
   filterConfig.getServletContext().log(iox.getMessage());
  }
 }
 public void destroy()
 {
 }
}
 


Ïà¹ØÎĵµ£º

jspÎļþ¿ªÍ·path, basePath×÷ÓÃ

ÔÚJSPÖеÄÈç¹ûʹÓà "Ïà¶Ô·¾¶"  ÔòÓпÉÄÜ»á³öÏÖÎÊÌâ. 
ÒòΪ ÍøÒ³ÖÐµÄ "Ïà¶Ô·¾¶" , ËûÊÇÏà¶ÔÓÚ "URLÇëÇóµÄµØÖ·" ȥѰÕÒ×ÊÔ´. 
ÉÏÃæÕâ¾ä»°ÊÇʲôÒâË¼ÄØ ? 
¾Ù¸öÀý×Ó: 
¼ÙÈçÎÒÃÇÓÐÒ»¸öÏîÄ¿: MyApp 
ÔÚ¸ÃÏîÄ¿ÏÂ, ÓÐÒ»¸öjspÎļþ¼Ð 
¸ÃÎļþ¼ÐϰüÀ¨: 
login.jsp    // ......

JSP ÈÝÆ÷µÄ³õʼ»¯ºÍÏú»Ù ServletContext£¨×ª£©

ServletContext ±» Servlet ³ÌÐòÓÃÀ´Óë Web ÈÝÆ÷ͨÐÅ¡£ÀýÈçдÈÕÖ¾£¬×ª·¢ÇëÇó¡£Ã¿Ò»¸ö Web
Ó¦ÓóÌÐòº¬ÓÐÒ»¸öContext£¬±»WebÓ¦ÓÃÄڵĸ÷¸ö³ÌÐò¹²Ïí¡£ÒòΪContext¿ÉÒÔÓÃÀ´±£´æ×ÊÔ´²¢ÇÒ¹²Ïí£¬ËùÒÔÎÒËùÖªµÀµÄ
ServletContext µÄ×î´óÓ¦ÓÃÊÇWeb»º´æ----°Ñ²»¾­³£¸ü¸ÄµÄÄÚÈݶÁÈëÄڴ棬ËùÒÔ·þÎñÆ÷ÏìÓ¦ÇëÇóµÄʱºò¾Í²»ÐèÒª½øÐÐÂýËٵĴŠ......

jspÖÐʹÓÃjavabeanµÄÁ½µã×¢ÒâÊÂÏî

jspÖÐʹÓÃjavabeanµÄÁ½µã×¢ÒâÊÂÏî
Ê×ÏÈÒ»µã£ºjavabeanÒ»¶¨Òª·ÅÔÚÃüÃû°üÀ²»ÄÜ·ÅÔÚĬÈϰüÀҲ¾ÍÊÇÔÚbeanÎļþµÄ¿ªÍ·Òªpackage¡¡pname;ÁË£¬Èç¹û²»·ÅÔÚÃüÃû°üÀï¶ø·ÅÔÚÁËĬÈϰüÀ×îºó½«±¨ÈçÏÂÕâÑùµÄ´íÎó£º
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 18 in the ......

×ܽ᣺JSPÒ³ÃæimgͼƬ»º´æÎÊÌâÏÖÏó±íÊö¼°ÎÊÌâ½â¾ö

JSPÒ³ÃæimgͼƬ»º´æÎÊÌâÏÖÏó±íÊö¼°ÎÊÌâ½â¾ö
l  ÎÊÌâ±íÊö£º
µ±¶Ôº¬ÓÐÍ·ÏñµÄ¿Í·þÈËÔ±ÐÅÏ¢½øÐÐÐÞ¸Ä(º¬¶ÔÍ·ÏñÐÅÏ¢µÄÐÞ¸Ä)ºó£¬ÖØÐ´ò¿ªÊý¾ÝÐ޸ĽçÃæ£¬·¢ÏÖÎı¾ÄÚÈÝÐ޸ijɹ¦£¬¶øÍ·ÏñÄÚÈÝÈÔÈ»ÏÔʾΪԭÀ´µÄÍ·Ïñ——Êý¾Ý¿âÖеĶÔÓ¦ÐÅϢͷÏñËùÔÚ×Ö¶ÎÊý¾ÝÒѾ­³É¹¦¸üС£
 
l  ǰÌ᣺
jspÒ³ÃæÖнøÐÐÁËҳà ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ