
Servlet & JSP
gemini18
这个作者很懒,什么都没留下…
展开
-
request里的一些getXXX()方法
假定请求的URL为 http://localhost:8080/news/addNews.do?type=1java 代码 request.getMethod(); // GET request.getServerName(); // localhost request.getServerPort(); // 8080 ...2007-01-09 22:51:41 · 571 阅读 · 0 评论 -
两种方法解决URL中的中文参数问题
假设请求的URL中问号后的字符串是:"country=中国"① String类的构造方法 String s = null; try { s = new String(request.getParameter("country").getBytes("ISO-8859-1"), "GBK"); } catch (Unsuppor...2007-01-23 23:18:44 · 273 阅读 · 0 评论 -
JSP中EL表达式无效的问题
确定用的Servlet / JSP的版本,查看web.xml的开头部分,如果有以下内容,表示是Servlet 2.4 / JSP 2.0。 <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3....2007-01-26 15:28:52 · 140 阅读 · 0 评论 -
web.xml中<url-pattern>的3种写法
① 完全匹配 <url-pattern>/test/list.do</url-pattern> ② 目录匹配 <url-pattern>/test/*</url-pattern> ③ 扩展名匹配 <url-pattern>*.do...2007-05-08 20:42:00 · 562 阅读 · 0 评论 -
Servlet中的文件下载
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/ja...2007-05-15 19:21:57 · 123 阅读 · 0 评论 -
Servlet中转发和重定向的路径问题
Servlet中有两种方式获得转发对象(RequestDispatcher):一种是通过HttpServletRequest的getRequestDispatcher()方法获得,一种是通过ServletContext的getRequestDispatcher()方法获得;重定向的方法只有一种:HttpServletResponse的sendRedirect()方法。这三个方法的参数都是一个U...2007-05-16 13:30:04 · 372 阅读 · 0 评论 -
JSTL中c:set标签的要点和技巧
c:set标签有两种不同的设置:var和target。var“版本”用于设置作用域属性,target“版本”用于设置bean属性或Map值。这两个版本都有两种形式:有体和没有体。有体的只是放入值的另一种途径。★ var“版本” <c:set var="userLevel" scope="session" value="Cowboy"/> ...2007-05-16 19:59:00 · 881 阅读 · 0 评论 -
在web.xml或JSP中指定错误页面
★ 在web.xml中,可以使用exception-type标签或HTTP状态码error-code标签声明错误页面。根据异常类声明错误页面: <error-page> <exception-type>java.io.IOException</exception-type> <location>/e...2007-05-21 12:31:00 · 541 阅读 · 0 评论 -
《Head First Servlets & JSP(中文版)》书摘
一直觉得自己Servlet的基础还有待加强,所以利用5.1七天假搞了本《Head First Servlets & JSP(中文版)》重新补一下基础,看的过程中摘录了一些知识点,罗列如下(括号中为知识点所在的页号):第4章 作为servlet:请求和响应★ 每个请求都在一个单独的线程中运行! 容器运行多个线程来处理对一个servlet的多个请求。 对应每个客户请求,容器会生...2007-05-21 18:55:22 · 202 阅读 · 0 评论