??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产精品成人午夜在线观看 ,亚洲伊人久久大香线蕉啊,亚洲AV永久纯肉无码精品动漫http://m.tkk7.com/ywj-316/category/42907.htmlzh-cnTue, 22 Jun 2010 17:12:38 GMTTue, 22 Jun 2010 17:12:38 GMT60防止面多次h提交表单Q{Q?/title><link>http://m.tkk7.com/ywj-316/archive/2010/06/21/324077.html</link><dc:creator>junly</dc:creator><author>junly</author><pubDate>Mon, 21 Jun 2010 09:33:00 GMT</pubDate><guid>http://m.tkk7.com/ywj-316/archive/2010/06/21/324077.html</guid><wfw:comment>http://m.tkk7.com/ywj-316/comments/324077.html</wfw:comment><comments>http://m.tkk7.com/ywj-316/archive/2010/06/21/324077.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/ywj-316/comments/commentRss/324077.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/ywj-316/services/trackbacks/324077.html</trackback:ping><description><![CDATA[<div class="tylfebb" id="BlogArticleDetail" style="font-size: 14px"> <p>当用户从表单处完成递交Q如无问题已注册信息写入数据库Q但有问题的是,如何防止用户h面Q这相当于将原有的信息再ơ写入数据库Q在|络上寻找解x法,试用后将本h认ؓ(f)最用的方法记下?/p> <p>|络中给出如下解x式:(x)</p> <p><font color="#ff6600">W一U:(x)用提交按钮</font></p> <p>当用h交表单后Q用JAVASCRIPT脚本语言Q将提交钮禁用?/p> <p>分析Q如客户端没有开启脚本功能就出现问题Q这也仅是在表单处理前有用,防止用户多次点击提交钮;现在很多|站都启用验证码解决此问题了(jin)?/p> <p><font color="#ff6600">W二U:(x)使用 Session</font></p> <p>在第一ơ写入数据库代码后,Session标记Q在数据库代码前判断Session是否曄标记qƈ与刚才的标记是否相等?/p> <p><font color="#808000">代码Q?/font></p> <p>Session("User") = True</p> <p>   Response.write "(zhn)刚才已l注册过?#8230;…"<br /> Else</p> <p>   ...... '省略写入数据库部?/p> <p>   Session("User") = True</p> <p>End if</p> <p>分析Q比较管用的Q但Session默认时效?0分钟Q虽然可以设|时效长度,但由于网站服务器讄不同Q也许达不到理想效果?/p> <p><font color="#ff6600">W三U:(x)重新定向</font></p> <p>注册完毕后直接将|页重新定向到其他页面?/p> <p><font color="#808000">代码Q?/font>Response.Redirect "Index.html"</p> <p>分析Q用此Ҏ(gu)Q需要配合客L(fng)脚本清除历史(history)才行Q没有试用,因ؓ(f)用户可以使用后退按钮Ql刷新?/p> <p><font color="#ff6600">W四U:(x)止~存</font></p> <p>在写入数据一|下边d下面的代码,然后导向新页Q可以用户点击后退按钮后,面提示|页q期?/p> <p><font color="#808000">代码Q?/font></p> <p>ASPQ?br /> Response.Buffer = True    <br /> Response.ExpiresAbsolute = Now() - 1    <br /> Response.Expires = 0    <br /> Response.CacheControl = "no-cache"</p> <p>ASP.NETQ?br /> Response.Buffer=true;<br /> Response.ExpiresAbsolute=DateTime.Now.AddSeconds(-1);<br /> Response.Expires=0;<br /> Response.CacheControl="no-cache";</p> <p>分析Q试用后Q发C个问题,虽然表面看到|页q期字样Q但在过期网上hQ仍可以再次h多次注册?/p> <p><font color="#ff6600">W五U:(x)用弹出窗?/font></p> <p>提交表单的时候弹出新H口Q在新窗口页面完成数据库的写入)(j)Q关闭本H口。对于window.open()打开的窗口是无法用后退按钮的?/p> <p><font color="#ff6600">W六U:(x)调数据库q行Ҏ(gu)</font></p> <p>q一U是得不偿失的方法,因ؓ(f)?x)加重服务器的负担,如果在表单没有进行AJAX方式的验证,q也是一U必要的Ҏ(gu)?/p> <p><font color="#808000">代码Q(假设已连接数据库Q?/font></p> <p>Dim Rs,SQL,UserId</p> <p>UserId = Request("Userid") '从表单从取数据内?/p> <p>If UserId <> "" then '不ؓ(f)I的时?br /> Set Rs=Server.CreateObject("Adodb.Recordset")<br />    SQL = "Select Userid From ?Where Userid='"& UserId &"'"<br />    Rs.Open Sql, Conn, 2, 2<br />   <br /> If Rs.Eof And Rs.Bof Then<br />    Response.Write "没有相同数据Q?<br /> Else<br />    Response.Write "有相同数据!"<br /> End If<br /> <br />    Rs.Close<br />    Set Rs = Nothing<br />    Response.End<br /> End If</p> <p> </p> <p>l过试Q如果不惛_费事Q直接用W六U方法,用户刷一ơ就Ҏ(gu)据库(g)索一ơ,q种方式最大的弊端是有可能把服务器篏死;</p> <p>׃Q我采用?jin)第二种?gu)Q结合了(jin)W四U(效果不大Q,在代码最前端加入?jin)验证由何处来本站的函数Q这样可以防止用戯己在本机模仿|站表单提交数据Q?a target="_blank">hi.baidu.com/76512/blog/item/b8d9be8f168d3aedf01f3680.html</a>Q,也可以防止用户在本站直接在网址末端加变量值刷新数据?/p> <p>׃在表单处已加入随机验证码Qƈ已写入Session中,在处理数据前Q可以先(g)Session是否为空Q空为已提交q了(jin)Q不为空是第一ơ提交,在第一ơ提交后该Session清空?/p> <p><font color="#808000">代码Q?/font></p> <p>If Session("RndNum") = ""<br />    Response.Write "已提交过数据?jin)呀Q?<br /> Else</p> <p>...... '省略写入数据库代?/p> <p>   Session("RndNum") = ""<br /> End if</p> <p>分析Q只要是从正常的途径递交的表单,Session("RndNum")的数g?x)?f)I的Q从非正帔R径Q比如说Q直接打开|址Q或在本机模拟表单递交Q或在网址后添加变量|是无法写入数据库的。Session默认?0分钟Q清I后仍然W合逻辑。也不怕用h开几个注册面Q来回刷新注册?br /> <br /> <br /> <br /> <br /> 用面~存的几U方法(静态和动态)(j)<br /> 1、在Asp面首部<head>加入   <br /> <table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0"> <tbody> <tr> <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片D:(x)</font><br />   Response.Buffer   =   True    <br />   Response.ExpiresAbsolute   =   Now()   -   1    <br />   Response.Expires   =   0    <br />   Response.CacheControl   =   "no-cache"    <br />   Response.AddHeader   "Pragma",   "No-Cache"  </td> </tr> </tbody> </table> <br />   2、在HtML代码中加?nbsp;  <br /> <table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0"> <tbody> <tr> <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片D:(x)</font><br />   <HEAD>    <br />   <META   HTTP-EQUIV="Pragma"   CONTENT="no-cache">    <br />   <META   HTTP-EQUIV="Cache-Control"   CONTENT="no-cache">    <br />   <META   HTTP-EQUIV="Expires"   CONTENT="0">    <br />   </HEAD>  </td> </tr> </tbody> </table>  <br />     <br />   3、在重新调用原页面的时候在l页面传一个参?nbsp;  Href="****.asp?random()"  </p> <p>  前两个方法据说有时会(x)失效Q而第三种则是在蟩转时传一个随机的参数Q?因ؓ(f)aspx的缓存是与参数相关的Q如果参C同就不会(x)使用~存Q而会(x)重新生成面Q每ơ都传一个随机的参数可以避免用缓存。这个仅适用于asp&asp.net</p> <p>  4、在jsp面中可使用如下代码实现无缓存:(x)</p> <p> <table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0"> <tbody> <tr> <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片D:(x)</font><br /> response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 <br /> response.setHeader("Pragma","no-cache"); //HTTP 1.0 <br /> response.setDateHeader ("Expires", 0); //prevents caching at the proxy server</td> </tr> </tbody> </table> </p> <p>  q些代码加在<head> </head>中间具体如下</p> <p> <table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0"> <tbody> <tr> <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片D:(x)</font><br /> <head> <br /> <% <br /> response.setHeader("Cache-Control","no-cache"); //HTTP 1.1 <br /> response.setHeader("Pragma","no-cache"); //HTTP 1.0 <br /> response.setDateHeader ("Expires", 0); //prevents caching at the proxy server <br /> %> <br /> </head></td> </tr> </tbody> </table> </p> <p>  5、window.location.replace("WebForm1.aspx");   <br />   参数是你要覆盖的页面,replace的原理就是用当前面替换掉replace参数指定的页面?nbsp;  <br /> q样可以防止用户点击back键。用的?a >javascript</a>脚本QD例如下:(x)</p> <p>  a.html</p> <p> <table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0"> <tbody> <tr> <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片D:(x)</font><br /> <html> <br />     <head> <br />         <title>a</title>      <br />         <script language="javascript"> <br />             function jump(){ <br />                 window.location.replace("b.html"); <br />             } <br />         </script> <br />     </head> <br />     <body> <br />        <a href="javascript:jump()">b</a> <br />    </body> <br /> </html>  </td> </tr> </tbody> </table> </p> <p>  b.html</p> <p> <table style="border-right: #cccccc 1px dotted; table-layout: fixed; border-top: #cccccc 1px dotted; border-left: #cccccc 1px dotted; border-bottom: #cccccc 1px dotted" cellspacing="0" cellpadding="6" width="95%" align="center" border="0"> <tbody> <tr> <td style="word-wrap: break-word" bgcolor="#f3f3f3"><font style="font-weight: bold; color: #990000">以下是引用片D:(x)</font><br /> <html> <br />     <head> <br />         <title>b</title>      <br />         <script language="javascript"> <br />             function jump(){ <br />                 window.location.replace("a.html"); <br />             } <br />         </script> <br />     </head> <br />     <body> <br />        <a href="javascript:jump()">a</a> <br />    </body> <br /> </html>  </td> </tr> </tbody> </table> </p> <p>  ?U只是清IZ(jin)cacheQ即存储在Temporary Internet Files文g夹中的(f)时文Ӟ而第五种则是使用跌{面文g替换当前面文gQƈ没有清空cacheQ也是说Temporary Internet Files产生?jin)相关的临时文gQ两者搭配用真是清I缓存,必备良药?/p> <p><br />  </p> </div> <img src ="http://m.tkk7.com/ywj-316/aggbug/324077.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/ywj-316/" target="_blank">junly</a> 2010-06-21 17:33 <a href="http://m.tkk7.com/ywj-316/archive/2010/06/21/324077.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>request.getRequestURI() 、request.getRequestURL() 、request.getContextPath()、request.getServletPath()区别http://m.tkk7.com/ywj-316/archive/2010/06/09/323190.htmljunlyjunlyWed, 09 Jun 2010 12:31:00 GMThttp://m.tkk7.com/ywj-316/archive/2010/06/09/323190.htmlhttp://m.tkk7.com/ywj-316/comments/323190.htmlhttp://m.tkk7.com/ywj-316/archive/2010/06/09/323190.html#Feedback0http://m.tkk7.com/ywj-316/comments/commentRss/323190.htmlhttp://m.tkk7.com/ywj-316/services/trackbacks/323190.html request.getRequestURL() http://localhost:8080/jqueryWeb/resources/request.jsp
request.getContextPath()/jqueryWeb
request.getServletPath()/resources/request.jsp


注:(x) resources为WebContext下的目录?br /> jqueryWeb 为工E名

-----------------------------------------------------
<%=request.getRequestURI() %><br/>
<%=request.getRequestURL() %><br/>
<%=request.getContextPath()%><br/>
<%=request.getServletPath() %><br/>
<%=request.getPathInfo() %><br/>
l果Q?br /> /test-struts.jsp
http://127.0.0.1:8080/test-struts.jsp

/test-struts.jsp
null

配置Q?br /> <action name="test" class="testStrutsAction" method="test"> 
   <result>/test-struts.jsp</result>
</action>



junly 2010-06-09 20:31 发表评论
]]>
生命周期http://m.tkk7.com/ywj-316/archive/2009/11/29/304178.htmljunlyjunlySun, 29 Nov 2009 14:50:00 GMThttp://m.tkk7.com/ywj-316/archive/2009/11/29/304178.htmlhttp://m.tkk7.com/ywj-316/comments/304178.htmlhttp://m.tkk7.com/ywj-316/archive/2009/11/29/304178.html#Feedback0http://m.tkk7.com/ywj-316/comments/commentRss/304178.htmlhttp://m.tkk7.com/ywj-316/services/trackbacks/304178.html 2 初始化:(x)该容器调用init()Ҏ(gu)
  init()
  init(ServletConfig config){
    config.getParamter("aaa");
  }
  web.xml
  <servlet>
 <param-name>aaa</param-name>
 <param-value>1</param-value>
  </servlet>
3 服务Q如果请求servlet,则容器调用service()Ҏ(gu)
4 销毁:(x)销毁实例前调用destroy()Ҏ(gu)

junly 2009-11-29 22:50 发表评论
]]>
内置对象http://m.tkk7.com/ywj-316/archive/2009/11/29/304177.htmljunlyjunlySun, 29 Nov 2009 14:49:00 GMThttp://m.tkk7.com/ywj-316/archive/2009/11/29/304177.htmlhttp://m.tkk7.com/ywj-316/comments/304177.htmlhttp://m.tkk7.com/ywj-316/archive/2009/11/29/304177.html#Feedback0http://m.tkk7.com/ywj-316/comments/commentRss/304177.htmlhttp://m.tkk7.com/ywj-316/services/trackbacks/304177.html一个javac,q行在服务器端的Q处理webh
//客户端蟩?br /> response.sendRedirect()
//服务器端跌{
RequsetDispatcher dispatcher=request.getRequestDispatcher("/...");
dispatcher.forward(request,response);
dispatcher.include()
1 out
struts中用PrintWriter out=request.getWriter()得到
2 request
(1)String getParameter(String name)         Ҏ(gu)面表单lg名称获取面提交数据
(2)String[] getParameterValues(String name) 获取一个页面表单组件对应多个值时的用L(fng)h数据
(3)void setCharacterEncoding(String name)   指定每个h的编码,在调用request.getParameter()Ҏ(gu)之前q行讄Q可以用于解决中文ؕ?br /> (4)request.getRequestDispatcher(String path)q回一个javax.servlet.RequestDispatcher对象Q该对象的forwardҎ(gu)用于转发h
   javax.servlet.RequestDispatcher dispatcher=request.getRequestDispatcher("/a.jsp(目标面)");
   dispatcher.forward(request,response);
3 response
response.sendRedirect(String location)重定向一个URL

4 session
(1)void setAttribute(String key,Object value)
(2)Object getAttribute(String key)
(3)HttpSession request.getSession()
(4)HttpSession request.getSession(boolean true)
(5)void session.setMaxInactiveInterval(2)//讄?x)话q期旉
(6)void invalidate()//销毁session,删除HttpSession对象?qing)数?br /> (7)void remove(String key)
(8)boolean isNew()//是否是最C(x)?br /> 在web.xml中配|session默认q期旉
 <session-config>
  <session-timeout>5</session-timeout>//单位为分?br />  </session-config>
5 applicate->servletContext
(1)void setAttribute(String key,Object value)
(2)Object getAttribute(String key)
6 pageContext
6 serviceҎ(gu)



junly 2009-11-29 22:49 发表评论
]]>
web服务Qweb ServiceQ?/title><link>http://m.tkk7.com/ywj-316/archive/2009/11/29/304176.html</link><dc:creator>junly</dc:creator><author>junly</author><pubDate>Sun, 29 Nov 2009 14:48:00 GMT</pubDate><guid>http://m.tkk7.com/ywj-316/archive/2009/11/29/304176.html</guid><wfw:comment>http://m.tkk7.com/ywj-316/comments/304176.html</wfw:comment><comments>http://m.tkk7.com/ywj-316/archive/2009/11/29/304176.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/ywj-316/comments/commentRss/304176.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/ywj-316/services/trackbacks/304176.html</trackback:ping><description><![CDATA[<p>web Service<br /> xml数据格式<br /> SOAPQ简单对象访问)(j)<br /> WSDL<br /> -----------<br /> 开发步?br /> 1 建立服务q发?br />   XFire<br />   × 导入jar?br />   * service.xml<br />   * web.xml<br />   <br />   创徏接口<br />   public interface IProcessCredit{<br />      public String sayHello(String username);<br />   }<br />   和实现类<br />   public class ProcessCreditImpt implement IProcessCredit{<br />      public String sayHello(String username){<br />         return "你好"+username;<br />      }<br />   }<br />   ~写配置文g<br />   services.xml<br />   <service><br />   <name>CreditCard</name><br />   <namespace>http://www.CreditCard.com</namespace><br />   <serviceClass><br />   org.com.IProcessCredit<br />   </serviceClass><br />   <implementationClass><br />   org.com.ProcessCreditImpt<br />   </implementationClass><br />   <br /> 2 客户端servlet调用服务<br />   1 导入Service的jar<br />   2 导入XFire的jar<br />   3 Service <br />   Service service=new ObjectServiceFactory().create(IProcessCredit.class);<br />   XFire xfire=XfireFactory.newInstance().getXFire();<br />   XFireProxyFactory factory=new XFireProxyFactory(xfire);<br />   String url="";<br />   IProcessCredit c=(IProcessCredit)factor.create(service,url);<br />   c.sayHello("ddddddddddd");</p> <p><br /> -----------------------------------------------------------------<br /> 步骤Q?br /> 1 建立接口<br /> public interface IBookService {<br />  public int addBook(Book book);<br /> }</p> <p>2 实现接口<br /> public class ProessBookService implements IBookService {<br />  public int addBook(Book book) {<br />   BookDao bookDao=new BookDao();<br />   return bookDao.addBook(book);<br />  }<br /> }</p> <p>3 在src下创建META-INF文g夹,在META-INF下创建xfire文g夹,在xfire下创建services.xml<br />   (src-->META-INF-->xfire-->services.xml)<br /> <service><br /> <name>BookService</name><br /> <namespace>http://www.book.com</namespace><br /> <serviceClass>org.book.IBookService </serviceClass><br /> <implementationClass>org.book.ProessBookService </implementationClass><br /> </service><br /> 4 ~写web.xml<br />   <servlet><br />   <servlet-name>XFireServlet</servlet-name><br />   <servlet-class>org.codehaus.xfire.transport.http.XFireConfigurableServlet</servlet-class><br />   </servlet><br />   <servlet-mapping><br />   <servlet-name>XFireServlet</servlet-name><br />   <url-pattern>/services/*</url-pattern><br />   </servlet-mapping><br /> 5 ~写调用Ҏ(gu)<br /> Service serviceModle=new ObjectServiceFactory().create(IBookService.class);<br /> XFire xFire=XFireFactory.newInstance().getXFire();<br /> XFireProxyFactory factory=new XFireProxyFactory(xFire);<br /> String urlString="http://localhost:8080/ownhome/services/ProessBookService";<br /> IBookService bookService=(IBookService) factory.create(serviceModle, urlString);</p> <img src ="http://m.tkk7.com/ywj-316/aggbug/304176.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/ywj-316/" target="_blank">junly</a> 2009-11-29 22:48 <a href="http://m.tkk7.com/ywj-316/archive/2009/11/29/304176.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>servletҎ(gu)o(h)?/title><link>http://m.tkk7.com/ywj-316/archive/2009/11/29/304174.html</link><dc:creator>junly</dc:creator><author>junly</author><pubDate>Sun, 29 Nov 2009 14:47:00 GMT</pubDate><guid>http://m.tkk7.com/ywj-316/archive/2009/11/29/304174.html</guid><wfw:comment>http://m.tkk7.com/ywj-316/comments/304174.html</wfw:comment><comments>http://m.tkk7.com/ywj-316/archive/2009/11/29/304174.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/ywj-316/comments/commentRss/304174.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/ywj-316/services/trackbacks/304174.html</trackback:ping><description><![CDATA[servletҎ(gu)o(h)?br /> 1 ~写实现javax.servlet.Filter接口的类<br /> public class MyFilter implements Filter {<br />  private FilterConfig config;<br />  private String encoding="IS0-8859-1";<br />  public void destroy() {//qo(h)器当前类被消灭时调用的方?br />  }<br />  public void doFilter(ServletRequest request, ServletResponse response,//qo(h)器主Ҏ(gu)<br />    FilterChain chain) throws IOException, ServletException {<br />   request.setCharacterEncoding(encoding);<br />   chain.doFilter(request, response);//讄其可被下个过滤器l箋调用<br />  }<br />  public void init(FilterConfig config) throws ServletException {//qo(h)器当前类初始化时调用此方?br />   this.config=config;<br />   String s=config.getInitParameter("encoding");//得到相应参数<br />   if(s!=null){<br />    encoding=s;<br />   }<br />  }<br /> }<br /> FilterConfigcȝ于获得初始化的参数的包装c?br /> FilterChaincLqo(h)器的链,可以多重qo(h)<br /> 2 配置Servletqo(h)?br /> <filter><br />    <filter-name>EncodingFilter</filter-name>qo(h)器名U?br />    <filter-class>com.webs.MyFilter</filter-class>对应c?br />    <init-param>参数<br />     <param-name>encoding</param-name>参数?br />     <param-value>UTF-8</param-value>参数?br />    </init-param><br /> </filter><br /> <filter-mapping>映射特定资源<br />   <filter-name>EncodingFilter</filter-name>qo(h)器名U?br />   <url-pattern>/*</url-pattern><br /> </filter-mapping><br /> 3 面<br /> 4 注意Q服务器端蟩转是不过滤的 <img src ="http://m.tkk7.com/ywj-316/aggbug/304174.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/ywj-316/" target="_blank">junly</a> 2009-11-29 22:47 <a href="http://m.tkk7.com/ywj-316/archive/2009/11/29/304174.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>servlet监听?/title><link>http://m.tkk7.com/ywj-316/archive/2009/11/29/304175.html</link><dc:creator>junly</dc:creator><author>junly</author><pubDate>Sun, 29 Nov 2009 14:47:00 GMT</pubDate><guid>http://m.tkk7.com/ywj-316/archive/2009/11/29/304175.html</guid><wfw:comment>http://m.tkk7.com/ywj-316/comments/304175.html</wfw:comment><comments>http://m.tkk7.com/ywj-316/archive/2009/11/29/304175.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/ywj-316/comments/commentRss/304175.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/ywj-316/services/trackbacks/304175.html</trackback:ping><description><![CDATA[<p>servlet监听?br /> 在WEB应用中响应特定对象的特定事g<br /> 好处:更方便的控制application,session,request对象的发生的特定事g<br />      可以集中处理特定的事?br /> -------------------------------------------------------------------<br /> HttpSession监听器接?br /> 1 HttpSessionListener(需要配web.xml)<br /> 2 HttpSessionAttributeListener(需要配web.xml)<br /> 3 HttpSessionBindingListener<br /> 4 HttpSessionActivationListener(需要配web.xml)<br /> -------------------------------------------------------------------<br /> HttpSessionListener<br /> 1 sessionCreated()//当session对象产生的时候调用的Ҏ(gu)<br /> 2 sessionDestroyed()//当session对象消灭的时候调用的Ҏ(gu)<br /> web.xml配置<br /> <listener><br />  <listener-class>webbook.chapter14.CounterListener(对应的实现类)<br />  </listener-class><br /> </listener><br /> ---------------------------------------------------------------------<br /> HttpSessionAttributeListener<br /> 1 attributeAdded()//d时调?br /> 2 attributeReplaced()//替换时调?br /> 3 attributeRemoved()//删除时调?br /> 产生事g的代?br /> session.setAttribute("username","wangwu");<br /> session.setAttribute("username","lisi");<br /> session.removeAttribute("username");<br /> -----------------------------------------------------------------<br /> HttpSessionBindingListener<br /> 1 valueBound();<br /> 2 vaoueUnbound();<br /> 调用机制<br /> 如果一个类实现?jin)HttpSessionBindingListener接口,则当q个cȝ对象通过session.setAttribute()被绑定到Session对象中时,<br /> 则该对象的valueBound()Ҏ(gu)被自动调?当这个对象从Session中删除时(调用session.invalidate()和session.removeAtrribute()<br /> Ҏ(gu),或Session对象q期)valueUnbound()Ҏ(gu)被自动调用.<br /> --------------------------------------------------------------------------------------------------------<br /> HttpSessionActivationListener<br /> 1 sessionDidActivate();<br /> 2 sessionWillPassivate();<br /> ---------------------------------------------------------------------------------<br /> 例子:<br /> 1 建立CounterListener处理c?br /> import javax.servlet.http.HttpSessionEvent;<br /> import javax.servlet.http.HttpSessionListener;<br /> public class CounterListener implements HttpSessionListener {</p> <p> private static long onlineNumber=0;<br />  public void sessionCreated(HttpSessionEvent se) {<br />   onlineNumber++;<br />  }</p> <p> public void sessionDestroyed(HttpSessionEvent se) {<br />   onlineNumber--;<br />  }<br />  <br />  public static long getOnlineNumber(){<br />   return onlineNumber;<br />  }<br /> }<br /> 2 配置web.xml<br /> <listener><br />     <listener-class>com.tags.CounterListener</listener-class><br /> </listener><br /> 3 JSP面<br /> <%@page import="com.tags.CounterListener;"%><br /> <body><br />     当前的在Uh敎ͼ(x)<%=CounterListener.getOnlineNumber() %> <br><br /> </body><br /> ----------------------------------------------------------------------------<br /> ServletContext监听器接?br /> ServletContextListener<br /> 1 contextInitialized()<br /> 2 contextDestroyed()<br /> 调用机制<br /> 当在web应用中部|了(jin)实现该接口的实现cd,在WEB容器加蝲WEB应用??启动服务?׃(x)自动调用contextInitialized()Ҏ(gu),<br /> 而当WEB容器销毁WEB应用??关闭服务?,?x)自动调用contextDestroyed()Ҏ(gu).<br /> -----------------------------------------------------------------------------------<br /> ServletContextAttributeListener<br /> 1 attributeAdded()<br /> 2 attributeReplaced()<br /> 3 attributeRemoved()<br /> 触发事g的代?br /> context.setAttribute("counter",new Integer(0));<br /> context.setAttribute("counter",new Integer(100));<br /> context.removeAttribute("counter");<br /> -----------------------------------------------------------<br /> HttpServletRequest监听?br /> ServletRequestListener<br /> 1 requestInitialized();<br /> 2 requestDestroyed()<br /> 调用机制<br /> 与ServletContextListener接口cM,在web应用中部|实现该接口的实现类?在HttpServletRequest对象(JSP中的request对象)建立<br /> 或者被销毁时,由web容器自动调用requestInitialized()或者requestDestroyed()Ҏ(gu).<br /> --------------------------------------------------------------------------------------<br /> ServletRequestAttributeListener<br /> 1 attributeAdded();<br /> 2 attributeReplaced();<br /> 3 attributeRemoved();<br /> 触发事g的代?br /> request.setAttribute("username","lisi");<br /> request.setAttribute("username","wangwu");<br /> request.removeAttribute("username");</p> <p>******************************************************************<br /> public class ListenerOnline implements HttpSessionLinstener,ServletContext{<br />   private  application;<br />   public void sessionCreated(HttpSessionEvent event){<br />     Integer n=(Integer)application.getAttrabute("z",1000);<br />     application.setAttrabute("z",n.IntValue()+1);<br />     <br />   }<br />    public void sessionDestroyed(HttpSessionEvent event){<br />   }<br />   public void contextInitialized(ServletContextEvent event){<br />     application=event.getServletContext();<br />     application.setAttrabute("z",1000);<br />   }<br />    public void contextDestroyed(ServletContextEvent event){<br />   }<br /> }</p> <p><listener><br />     <listener-class>com.tags.ListenerOnline</listener-class><br /> </listener></p> <p><meta http-equiv="refresh" content="3"/></p> <img src ="http://m.tkk7.com/ywj-316/aggbug/304175.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/ywj-316/" target="_blank">junly</a> 2009-11-29 22:47 <a href="http://m.tkk7.com/ywj-316/archive/2009/11/29/304175.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>servlet基础http://m.tkk7.com/ywj-316/archive/2009/11/29/304173.htmljunlyjunlySun, 29 Nov 2009 14:46:00 GMThttp://m.tkk7.com/ywj-316/archive/2009/11/29/304173.htmlhttp://m.tkk7.com/ywj-316/comments/304173.htmlhttp://m.tkk7.com/ywj-316/archive/2009/11/29/304173.html#Feedback0http://m.tkk7.com/ywj-316/comments/commentRss/304173.htmlhttp://m.tkk7.com/ywj-316/services/trackbacks/304173.html-HttpServletRequest request对象

request.getParameter("param");

request.setAttribute("loginname",object);

request.setCharacterEncoding("gb2312");
输入内容转成中文
-HttpServletResponse response对象

response.setContentType("text/html;charset=gb2312");
讄输出Z?br /> response.sendRediredt("url");

-RequsetDispatcher dispatcher=request.getRequestDispatcher(url);
定义转发?br /> dispatcher.forward(request,response);

-HttpSession session对象
创徏对象的两U方?br /> HttpSession session = request.getSession(boolean value);
HttpSession session = request.getSession();
Ҏ(gu)一QtrueӞq回该当前请求相关的?x)话Q如果不存在创徏一个新的会(x)话,q返回?br />      falseӞq回该当前请求相关的?x)话Q如果不存在q回nullQ不创徏?x)话?br /> Ҏ(gu)二:(x){同于方法一为true时?br /> HttpSession接口的方?br /> session.setAttribute(String name,Object value);
session.getAttribute(String name);//q回Object
session.removeAttribute(String name);//删除
session.invalidate()//当前?x)话关?br /> */

/*
dxml文g中的参数?br /> web.xml
<servlet>
  <init-param>
    <param-name>repeat</param-name>
    <param-value>10</param-value>
  </init-param>
</servlet>
servlet.java
int repeat=Integer.parseInt(this.getInitParameter("repeat"));
*/

/*
得到当前servlet相当信息的方?br /> request.getServerName()//得到当前h的服务器名子
request.getRemoteAddr()得到当前h服务器的IP地址
request.getServerPort()得到当前h服务器的端口?br /> request.getProtlcol()得到当前h的协议版?br /> request.getContextPath()得到当前h的上下文地址
request.getScheme()得到当前h的协议类?br /> request.getMethod()得到当前h的提交方式GET
request.getRequestURI()得到当前服务器servlet的映\径,带上下文
request.getServletPath()得到当前服务器servlet的映\?/p>

servlet的头信息
Enumeration e=request.getHeaderNames();得到包含header名子的EnumerationcdŞ对象
request.getHeader()得到header名子对应的?br /> 例子Q?br /> Enumeration e=request.getHeaderNames();
String name="";
while(e.hasMoreElements)
{
  name=(String)e.nextElement();
  System.out.println(name);
  System.out.println(request.getHeader(name));
}

JSValidation验证框架
url:http://cosoft.org.cn/projects/jsvalidateion
修改validation-framwork.js
var ValidationRoot="/webproject2/js/"
配置validation-config.xml

FCKeditor文本~辑lg
http://www.fckeditor.net/download



junly 2009-11-29 22:46 发表评论
]]>
properties配置文ghttp://m.tkk7.com/ywj-316/archive/2009/11/29/304172.htmljunlyjunlySun, 29 Nov 2009 14:45:00 GMThttp://m.tkk7.com/ywj-316/archive/2009/11/29/304172.htmlhttp://m.tkk7.com/ywj-316/comments/304172.htmlhttp://m.tkk7.com/ywj-316/archive/2009/11/29/304172.html#Feedback0http://m.tkk7.com/ywj-316/comments/commentRss/304172.htmlhttp://m.tkk7.com/ywj-316/services/trackbacks/304172.html1 在src下徏config.properties文g
config.properties
uname=aaa
pwd=123
2
 InputStream in=this.getClass().getResourceAsStream("/config.properties");
 //in=new FileInputStream("D:/config.properties");
 Properties pro=new Properties();
 try{
  pro.load(in);
  pro.loadFromXML();
  pro.getProperty("uname");
  //(String)pro.get("uname");
  pro.put(key,"value");
 }

class
class.forName(String className)
q行中的对象都是class的一个实例,相关技?反射
class.getResourceAsStream(String fileName)
查找hl定名称的资?/p>

Resultcdjava.servlet.jsp.jstl.sql.Result包中,可以在关闭连接的状态下使用
stmt=conn.createStatement();
rs=stmt.executeQuery(sql);
Result result=ResultSupport.toResult(rs);
if(result==null){
 System.out.println("无数?);
}
for(int i=0;i<result.getRowCount();i++){
 Map map=result.getRows()[i];
 map.get("username");
}

作业Q连接池Q配|文?br /> <embed src=""/>
歌手表,gid,sex,name,love
歌曲?id,name,gid,typeid,歌词
cd?typeid,name
url
controls.play()
controls.stop()



junly 2009-11-29 22:45 发表评论
]]>
字符转换http://m.tkk7.com/ywj-316/archive/2009/11/29/304161.htmljunlyjunlySun, 29 Nov 2009 14:30:00 GMThttp://m.tkk7.com/ywj-316/archive/2009/11/29/304161.htmlhttp://m.tkk7.com/ywj-316/comments/304161.htmlhttp://m.tkk7.com/ywj-316/archive/2009/11/29/304161.html#Feedback0http://m.tkk7.com/ywj-316/comments/commentRss/304161.htmlhttp://m.tkk7.com/ywj-316/services/trackbacks/304161.htmlrequest.setCharacterEncoding("gbk");
response.setCharacterEncoding("text/html;charset=gbk");
String name=request.getParameter("username");

name=new String (name.getBytes("iso-8859-1"),"gbk");

1 qo(h)?br /> HttpServletRequest req=(HttpServletRequest)request;
request.setCharacterEncoding("gbk");
china.do();
2 子控制器
public class ToChinese extends RequestProcessor{
 public boolean processProcess(HttpServletRequest req,HttpServletRespone rep){
  request.setCharacterEncoding("gb2312");
  return true;
 }
}
struts-config.xml
<controller processorClass="com.org.ToChinese"/>



junly 2009-11-29 22:30 发表评论
]]>
JSP-自定义函数库http://m.tkk7.com/ywj-316/archive/2009/11/29/304162.htmljunlyjunlySun, 29 Nov 2009 14:30:00 GMThttp://m.tkk7.com/ywj-316/archive/2009/11/29/304162.htmlhttp://m.tkk7.com/ywj-316/comments/304162.htmlhttp://m.tkk7.com/ywj-316/archive/2009/11/29/304162.html#Feedback0http://m.tkk7.com/ywj-316/comments/commentRss/304162.htmlhttp://m.tkk7.com/ywj-316/services/trackbacks/304162.html 1 定义cdҎ(gu)(Ҏ(gu)必须是public static)
package com.bjsxt.struts;
public class MyFunctios{
  public static String sayHello(String name){
    return "Hello "+name;
  }
}
2 ~写自定义tld文gQƈ且将此文件放在WEB-INF或WEB-INF的Q意子目录?br /> <?xml version="1.0" encoding="UTF-8"?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" 
    version="2.0"> 
   
    <description>my functions library</description>
    <display-name>my functions</display-name>
    <tlib-version>1.0</tlib-version>
    <short-name>my</short-name>
    <uri>http://www.bjsxt.com/functions</uri>
    <function>
      <name>say</name>
      <function-class>com.bjsxt.struts.MyFunctions</function-class>
      <function-signature>java.lang.String sayHello(java.lang.String)</function-signature>
    </function>
</taglib>
3 在web.xml中注册(建意Q可以不注册Q?br />   <jsp-config>
   <taglib>
    <taglib-uri>http://www.bjsxt.com/functions</taglib-uri>
    <taglib-location>/WEB-INF/my.tld</taglib-location>
   </taglib>
  </jsp-config>
4 在JSP中采用taglib指o(h)引入自定义函数库
<%@ taglib prefix="my" uri="com.bjsxt.struts.MyFunctions"%>
5 调用
${my:say("jack")}

junly 2009-11-29 22:30 发表评论
]]>
Tag Library-定制标记?/title><link>http://m.tkk7.com/ywj-316/archive/2009/11/29/304160.html</link><dc:creator>junly</dc:creator><author>junly</author><pubDate>Sun, 29 Nov 2009 14:29:00 GMT</pubDate><guid>http://m.tkk7.com/ywj-316/archive/2009/11/29/304160.html</guid><wfw:comment>http://m.tkk7.com/ywj-316/comments/304160.html</wfw:comment><comments>http://m.tkk7.com/ywj-316/archive/2009/11/29/304160.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/ywj-316/comments/commentRss/304160.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/ywj-316/services/trackbacks/304160.html</trackback:ping><description><![CDATA[<p>定制标记?br /> 1 ~写标记处理c?br /> public class TimerTag extends TagSupport{<br />  private long start;<br />  private long end;<br />  public int doStartTag(){       //doStartTag标记开始方?br />   start=System.currentTimeMillis();<br />   return EVAL_BODY_INCLUDE;//<br />  }<br />  public int doEndTag() throws JspTagException {//doEndTag标记l束Ҏ(gu)<br />   end=System.currentTimeMillis();<br />   long elapsed=end-start;<br />   try{<br />    JspWriter out=pageContext.getOut();<br />    out.println("running time:"+elapsed+"ms.");<br />   }catch(IOException e){<br />    throw new JspTagException(e);<br />   }<br />   return EVAL_PAGE;//<br />  }<br /> }<br /> 2 ~写.tld文g<br /> <?xml version="1.0" encoding="UTF-8"?><br /> <taglib xmlns="http://java.sun.com/xml/ns/j2ee"  <br />     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  <br />     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"  <br />     version="2.0">  <br />   <br />     <description>custion web utility tags</description> //对当前标记库的描q?nbsp; <br />     <tlib-version>1.0</tlib-version>   //当前标记库的版本  <br />     <short-name>util</short-name>  //对当前标记库使用时的前缀名称  <br />     <uri>http://163.com</uri> //可Q?br />      <br />      <tag>  <br />          <description>calc code running time</description>  //对当前标记的描述  <br />          <name>timer</name>  //标记我名U?br />            <tag-class>com.tags.TimerTag</tag-class> 当前标记对应的处理类的具体名U?br />            <body-content>JSP</body-content>  //可有empty,JSP  <br />      </tag>  <br />  </taglib>  <br /> 3 使用格式<br /> jsp面<br /> <%@ taglib prefix="util" uri="http://163.com" %> d指o(h)<br /> <util:timer></util:timer></p> <p>ȝQ?br /> TLD是一个XML文gQ在WEB-INF目录?br /> <taglib>根元?br />  <tlib-version>version</tlib-version>标记库的版本<br />  <short-name>prefix</short-name>前缀名称<br />  <uri>uri</uri>引用的地址<br />  ...<br />  <tag><br />   <name>tagname</name>标记名称<br />   <tag-class>classname</tag-class>标记对应的处理类<br />   <tei-class>classname</tei-class>标记处理cȝ辅助处理c?br />   <body-content>[JSP,empty,scriptless,tagdependent]</body-content><br />   //jsp表示标记中可以包含html,java代码Q这些代码可以被q行<br />   //empty表示标记中不包含内容<br />   //scriptless表示标记中可以包含EL,jsp的动作代码,不可以包括JAVA脚本代码<br />   //tagdependent表示标记中可以包?br />   <attribute>标记的属?br />              <name>pattern</name>属性的名称<br />              <required>false</required>表示该属性是否是必须?br />              <rtexprvalue>false</rtexprvalue>该属性是否可以是JSP的表辑ּ<br />     </attribute>   <br />  </tag><br /> </taglib></p> <p>TagSupportq行原理Q不能对标记所包含的内容进行二ơ加工)(j)<br />  <img height="264" alt="" src="http://m.tkk7.com/images/blogjava_net/ywj-316/5.jpg" width="584" border="0" /><br />         <br /> BodyTagSupportq行原理(可以对开始和l束标记所包含的内容进行处?<br /> <img height="270" alt="" src="http://m.tkk7.com/images/blogjava_net/ywj-316/4.jpg" width="749" border="0" />   <br />           <br />  public int doAfterBody()throws JspTagException{<br />   BodyContent bc=getBodyContent();取内?br />   String input=bc.getString();取内?br />   JspWriter out=bc.getEnclosingWriter();<br />   <br />   String newContent=input;<br />   try{<br />    out.println(newContent);<br />   }catch(IOException e){<br />    throw new JspTagException(e);<br />   }<br />   return 1;<br />  }</p> <img src ="http://m.tkk7.com/ywj-316/aggbug/304160.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/ywj-316/" target="_blank">junly</a> 2009-11-29 22:29 <a href="http://m.tkk7.com/ywj-316/archive/2009/11/29/304160.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Tag Library-标记打包http://m.tkk7.com/ywj-316/archive/2009/11/29/304159.htmljunlyjunlySun, 29 Nov 2009 14:20:00 GMThttp://m.tkk7.com/ywj-316/archive/2009/11/29/304159.htmlhttp://m.tkk7.com/ywj-316/comments/304159.htmlhttp://m.tkk7.com/ywj-316/archive/2009/11/29/304159.html#Feedback0http://m.tkk7.com/ywj-316/comments/commentRss/304159.htmlhttp://m.tkk7.com/ywj-316/services/trackbacks/304159.htmlTag Library JAR
标记库打?br /> 1 前徏一个(f)时文件temp
2 把当前工作空间下的classes文g夹下的文件复制到temp文g夹下
3 在temp文g夹下新徏WEB-INF文g?br /> 4 把当前项目下的WEB-INF目录下的.tld文g复到到temp中WEB-INF文g夹下
5 启用DOSQ进入temp目录?br /> 6 q行命o(h)Qjar -cvf mytags.jar *
mytags生成的jar文g?br /> *代表temp文g下的所有文?br /> 7 其他目要用时将该jar文g复制到项目的lib目录下就可以?/p>

开源定制标记库
JSTL
Jakarta Taglibs http://jakarta.apache.org/taglibs/index.html
Display tag http://displaytag.sf.net



junly 2009-11-29 22:20 发表评论
]]>
JSTLhttp://m.tkk7.com/ywj-316/archive/2009/11/29/304158.htmljunlyjunlySun, 29 Nov 2009 14:19:00 GMThttp://m.tkk7.com/ywj-316/archive/2009/11/29/304158.htmlhttp://m.tkk7.com/ywj-316/comments/304158.htmlhttp://m.tkk7.com/ywj-316/archive/2009/11/29/304158.html#Feedback0http://m.tkk7.com/ywj-316/comments/commentRss/304158.htmlhttp://m.tkk7.com/ywj-316/services/trackbacks/304158.htmlJSTL
------------------------------------------------------------------------------
功能领域   URI                                    前缀   描述
Core       http://java.sun.com/jsp/jstl/core       c     核心(j)标记?br /> format     http://java.sun.com/jsp/jstl/fmt        fmt   格式化标记库-q间、日期、国际化
SQL        http://java.sun.com/jsp/jstl/sql        sql   Ҏ(gu)据库的操?br /> XML        http://java.sun.com/jsp/jstl/xml        xml   对XML的操?br /> Functions  http://java.sun.com/jsp/jstl/functions  fn    函数标记库,主要是字W串
用在视图层的技?br /> --------------------------------------------------------------------------------
用Q?br /> 1 引用标记?br /> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<body>
用户名:(x)<c:out value="${username}" />
</body>
</html>
-----------------------------------------------------------------------------------
Core核心(j)标记?br /> 操作变量     条g操作     循环操作     URI操作
out          if           forEach      import
set          choose       forTokens    url
remove       when                      redirect转向
catch        otherwise                 param
--------------------------------------------------------------------------------------
<c:out>标记
使用语法
1 <c:out value="vlaue" [escapeXml="{true|false}"]
   [default="defaultValue"] />
2 <c:out value="vlaue" [escapeXml="{true|false}"]>
   default value
  </c:out>
属?br /> ------------------------------------------------------------------------
属性名      | 描述                                                              | EL    | 必?nbsp; | ~省?br /> value          | 需要输出的|可以是EL表达式或帔R  | 可以  | ?nbsp;   | ?br /> default        | valuegؓ(f)I时所输出的内?nbsp;                      | 可以  | ?nbsp;   | ?br /> escapeXml | 为true对输出内容中?lt;?gt;???amp;        | 可以  | ?nbsp;   | true
                  | 字符q行转义Q分别{成都?amp;lt,&gt,      |       |       |
                  | ',"?amp;amp.为false不进行{?|       |       |
------------------------------------------------------------------------
<c:set>标记
使用语法
1 <c:set value="value" var="name" [scope="{page|request|session|application}"] />
2 <c:set var="name" [scope="{page|request|session|application}"]>
  value
  </c:set>
3 <c:set var="name" target="target" property="propertName">
4 <c:set target="target" propert="propertyName">
  value
  </c:set>
3?是给已有的对象属性赋?br /> 属?br /> -----------------------------------------------------------------------------
属性名    | 描述                                                                      | EL    | 必?nbsp; | ~省?br /> value        | 要保存的内容,可以是EL表达式或帔R             | 可以  | ?nbsp;   | ?br /> target       | 要修改属性的对象?一般ؓ(f)javaBeans对象?| 可以  | ?nbsp;   | ?br /> property  | 要修改的javaBeans的属?nbsp;                                   | 可以  | ?nbsp;   | ?br /> var          | 要保存内容的变量?nbsp;                                           |  ?nbsp;  | ?nbsp;   | ?br /> scope     | 保存内容的变量的作用范围                                 |  ?nbsp;  | ?nbsp;   | page
-----------------------------------------------------------------------------
<c:remove>标记
使用语法
<c:remove var="name" [scope="{page|request|session|application}"] />
属?br /> ------------------------------------------------------------------------------------------------
属性名    | 描述                                              | EL  | 必?nbsp; | ~省?br /> var           | 被删除的变量的名?nbsp;                 | ?nbsp; | ?nbsp;   | ?br /> scope       | 被删除的变量的作用范?nbsp;         | ?nbsp; | ?nbsp;   | page,request,session,application
------------------------------------------------------------------------------------------------
<c:catch>标记
使用语法
<c:catch [var="name"]>
 body content
</c:catch>
属?br /> ------------------------------------------------------------------------
属性名    | 描述                                                   | EL  | 必?nbsp; | ~省?br /> var           | 用来保存q例信息的变量名            | ?nbsp; | ?nbsp;   | ?br /> ------------------------------------------------------------------------
例子:
<c:catch var="ex">
    <%
     String number="none";
     int i=Integer.parseInt(number);
    %>
</c:catch>
${ex}
违例信息保存在ex变量?如没有发生违?则什么也不作

<c:if>标记
使用语法
1 <c:if test="condition" var="name" [scope="{page|request|session|application}"] />
2 <c:if test="condition" [var="name"] [scope="{page|request|session|application}"]>
 body content
</c:if>
属?br /> -----------------------------------------------------------------------------
属性名    | 描述                                                             | EL    | 必?nbsp; | ~省?br /> test           | 判断所要用的条g                                 | 可以  | ?nbsp;   | ?br /> var           | 保存条gl果的变量的名称                     | ?nbsp;   | ?nbsp;   | ?br /> scope       | 保存条gl果的变量的作用范围             | ?nbsp;   | ?nbsp;   | page
-----------------------------------------------------------------------------
<c:choose>标记
使用语法
<c:choose>
 body content(<when>and<otherwise>)
</c:choose>

<c:when>标记
使用语法
<c:when test="condition">
 body content
</c:when>
属?br /> -----------------------------------------------------------------------------
属性名    | 描述                                                                    | 动?nbsp; | 必?nbsp; | ~省?br /> test           | 如果它的l果为true,执行<c:when>所包含?nbsp; | 可以  | ?nbsp;   | ?br />                 | 内容,false则不执行<c:when>所包含的内?nbsp;     |       |       |
-----------------------------------------------------------------------------
<c:otherwise>标记
使用语法
<c:otherwise>
 body content
</c:otherwise>
---------------------------------------------------------------------------
例子:
<c:choose>
    <c:when test="${param.age>=70}">
      70以上
    </c:when>
    <c:when test="${param.age>35 and param.age<70}">
      35-70
    </c:when>
    <c:otherwise>
      35以下
    </c:otherwise>
</c:choose>
--------------------------------------------------------------------------------------------
<c:forEach>标记
使用语法
1 <c:forEach [var="name"] items="collection" [varStatus="varStatusName"]
   [begin="begin"] [end="end"] [step="step"]>
     body content
  </c:forEach>
2 <c:forEach [var="name"] items="collection" [varStatus="varStatusName"]
   begin="begin" end="end" [step="step"]>
     body content
  </c:forEach>
属?br /> ------------------------------------------------------------------------------------------------------------------------------
属性名    | 描述                                | EL    | 必?nbsp; | cd                                            |~省?br /> begin        | 开始下?nbsp;                       | 可以  | ?nbsp;   | int                                                 |0
end          | l束下标                        | 可以  | ?nbsp;   | int                                                  |集合中最后一个成员的索引
step         | 步长                                 | 可以  | ?nbsp;   | int                                                 |1
var          | 代表当前成员的变量名 |  ?nbsp;  | ?nbsp;   | String                                              |?br /> items       | q得循环的集?nbsp;            |  ?nbsp;  | ?nbsp;   | String,数组,Map,Collection,Iterator,Enumeration |?br /> varStatus | 昄循环状态的变量     | 可以  | ?nbsp;   | String                                          |?br /> -------------------------------------------------------------------------------------------------------------------------------
varStatus属?br /> ----------------------------------------------------------
名称    | cd     | 描述   
index   | int      | 现在所操作的成员的索引 
count   | int      | 现在所操作的成员的L 
first   | boolean  | 现在所操作的成?是否为第一个成?nbsp;  
last    | boolean  | 现在所操作的成?是否为最后一个成?nbsp; 
----------------------------------------------------------
<%
    String names[]=new String[4];
    names[0]="afdsaf";
    names[1]="dggh";
    names[2]="bcbncn";
    names[3]="434535";
    pageContext.setAttribute("names",names);
    Map map=new HashMap();
    map.put("k1","v1");
    map.put("k2","v2");
    request.setAtrribute("map1",map);
%>
    <c:forEach items="${names}" var="name" begin="1" end="2" step="1" varStatus="i">
     ${name } ${i.index } ${i.count } ${i.first } ${i.last }<br/>
    </c:forEach>
    <c:forEach items="${map1}"  var="v">
     ${v.key } = ${v.value }<br/>
    </c:forEach>

<c:forTokens>标记 一个字W串q行分隔
使用语法
<c:forTokens items="stringOfTokens" delims="delimiters" [var="name"]
   [varStatus="varStatusName"] [begin="begin"] [end="end"] [step="step"]>
     body content
</c:forTokens>
属?br /> ------------------------------------------------------------------------------------------
属性名    | 描述                                 | EL    | 必?nbsp; | cd      |~省?br /> items        | q行q代处理的变?nbsp;    | 可以  | ?nbsp;   | String    |?br /> delims      | 分割W号                         | 可以  | ?nbsp;   | char      |?br /> begin        | 开始下?nbsp;                        | 可以  | ?nbsp;   | int       |0
end         | l束下标                          | 可以  | ?nbsp;   | int       |集合中最后一个成员的索引
step        | 步长                                  | 可以  | ?nbsp;   | int       |1
var         | 代表当前成员的变量名   |  ?nbsp;  | ?nbsp;   | String    |?br /> varStatus | 昄循环状态的变量     |  ?nbsp;  | ?nbsp;   | String    |?br /> -------------------------------------------------------------------------------------------
<c:forTokens items="dsf:dsafsa:dsffs,dfdfs" var="name" delims=":,">
    ${name }<br/>
</c:forTokens>
-------------------------------------------------------------------------------------------
<c:import>标记 相当于include另外一个页面的内容引入到当前页面来
使用语法
1 <c:import url="url" [context="context"] [var="name"] [scope="{page|request|session|application}"]
   [charEncoding="charEncoding"]>
     <c:param>//可传参数
  </c:import>
2 <c:import url="url" [context="context"] varReader="varReaderName"
   [charEncoding="charEncoding"]>
     body content//内容
  </c:import>
属?br /> ------------------------------------------------------------------------------------------
属性名           | 描述                                                                 | EL    | 必?nbsp; |~省?br /> url                   | 需要导入页面url地址                                       | ?nbsp;   | ?nbsp;   |?br /> context            | 本地web应用的名?nbsp;                                      | ?nbsp;   | ?nbsp;   |当前应用的名?br /> charEncoding  | 讄导入数据的字W编?nbsp;                              | ?nbsp;   | ?nbsp;   |ISO-8859-1
var                  | 接受导入文本的变量的名称                           | ?nbsp;   | ?nbsp;   |?br /> scope            | 接受导入文本内容的变量的作用范围              | ?nbsp;   | ?nbsp;   |page
varReader     | 用于接受导入文本的java.io.Reader变量的名U?| ?nbsp;   | ?nbsp;   |?br /> -------------------------------------------------------------------------------------------

<c:url>标记 创徏链接
使用语法
1 <c:url value="value" [context="context"] [var="name"] [scope="{page|request|session|application}"] />
2 <c:url value="value" [context="context"] [var="name"] [scope="{page|request|session|application}"] />
    <c:param />
  </c:url>
属?br /> ------------------------------------------------------------------------------------------
属性名       | 描述                                             | EL    | 必?nbsp; |~省?br /> value           | url地址                                         | ?nbsp;   | ?nbsp;   |?br /> context       | web应用的名?nbsp;                          | ?nbsp;   | ?nbsp;   |当前web应用的名?br /> var             | 保存url地址的变量的名称          | ?nbsp;   | ?nbsp;   |输出到当前页?br /> scope         | 存储url地址的变量的作用范围   | ?nbsp;   | ?nbsp;   |page
-------------------------------------------------------------------------------------------
<c:url var="website" value="http://localhost:8080/webproject/out.jsp">
    <c:param name="p" value="hello" />
</c:url>
${website }<br>
<a href=" ${website }">dddd</a>
--------------------------------------------------------------------------------
<c:redirect>标记 面跌{
使用语法
1 <c:redirect url="value" [context="context"] />
2 <c:redirect url="value" [context="context"]>
    <c:param />
  </c:redirect>
属?br /> ------------------------------------------------------------------------------------------
属性名        | 描述                                             | 必?nbsp; |~省?br /> url                | url地址                                         | ?nbsp;   |?br /> context         | 要{向到的web应用的名?nbsp;      | ?nbsp;   |当前web应用的名?br /> -------------------------------------------------------------------------------------------
<c:redirect url="LoopTag.jsp">
     <c:param name="p" value="aa" />
</c:redirect>
-------------------------------------------------------------------------------


Format标记?br /> -----------------------------------------
国际化有?nbsp;       | 旉日期有关(一般不在页面作处理)
setLocale         | formatNumber
requestEncoding   | formatDate
bundle            | parseDate
message           | parseNumber
param             | setTimeZone
setBundle         | timeZone
-----------------------------------------
<fmt:setLocale>标记  讄国际化语a
使用语法
<fmt:setLocale value="locale" [variant="variant"] [scope="{page|request|session|application}"] />
属?br /> ---------------------------------------------------------------------------------------------------------------------------
属性名        | 描述                                                                                | EL    | 必?nbsp; |~省?br /> value         | 表示该语a环境的一个字W串Q或者是java.util.Localecȝ对象                          | 可以  | ?nbsp;   |?br /> scope         | 指定q个对象的作用范_(d)有效gؓ(f)page,requset,session,applicattion                   | ?nbsp;   | ?nbsp;   |page
variant       | q一步针对特定的q_或供应商定制语言环境。如,MAC和W(xu)IN分别对应Macintosh和W(xu)indowsq_ | 可以  | ?nbsp;   |?br /> ---------------------------------------------------------------------------------------------------------------------------
<fmt:setBundle>标记  讑֮国际化资源束的位|?br /> 使用语法
<fmt:setBundle basename="basename" [var="name"] [scope="{page|request|session|application}"] />
属?br /> ---------------------------------------------------------------------------------------------------------------------------
属性名        | 描述                                                                                | EL    | 必?nbsp; |~省?br /> basename      | 讄使用的资源文件束文g的\径与名称Q不应当包含M本地化后~或文件扩展名          | 可以  | ?nbsp;   |?br /> var           | 讄?jin)该属性,那么把basename属性所标识的资源束赋给该属性值所命名的变?nbsp;           | ?nbsp;   | ?nbsp;   |?br /> scope         | 指明~省资源束设|所应用的JSP作用?nbsp;                                                | ?nbsp;   | ?nbsp;   |page
---------------------------------------------------------------------------------------------------------------------------
束文件名resources_zh_CN.properties(basename属?
<fmt:setBundle basename="com.v512.examples.resources" />

<fmt:bundle>标记  讑֮某个面或某几行国际化资源束的位|?br /> 使用语法
<fmt:bundle basename="basename" [prefix="prefix"]>
  body content
<fmt:bundle>
属?br /> ---------------------------------------------------------------------------------------------------------------------------
属性名        | 描述                                                                                | EL    | 必?nbsp; |~省?br /> basename      | 讄使用的资源文件束文g的\径与名称Q不应当包含M本地化后~或文件扩展名          | 可以  | ?nbsp;   |?br /> prefix        | 为所嵌套?lt;fmt:message>标记的key值指定缺省前~                                      | 可以  | ?nbsp;   |?br /> ---------------------------------------------------------------------------------------------------------------------------

<fmt:message>标记  (核心(j))讄资料束文件中的KEY和对应的内容
使用语法
1 <fmt:message key="messageKey" [bundle="resourceBundle"] [var="varName"] [scope="{page|request|session|application}"] />
2 <fmt:message [bundle="resourceBundle"] [var="varName"] [scope="{page|request|session|application}"]>
  key
  [<fmt:param>]
  </fmt:message>
属?br /> -----------------------------------------------------------------------------------------------------------------------------------------------
属性名       | 描述                                                                                                                                                                                | EL    | 必?nbsp; |~省?br /> key             | 用来定在资源束中定义哪个文本消息进行输出显C?nbsp;                                                                                             | 可以  | ?nbsp;   |?br /> bundle        | 用来指定一个显式的资源?用来查找由key属性标识的消息.h?该属性的值必L实际的资源束.             | 可以  | ?nbsp;   |?br />                   | 如当指定<fmt:setBundle>操作的var属性时同该标记所赋予的资源束.<fmt:message>的bundle属性不支持字符串?nbsp;                                   
var             | 该标记所生成的文本消息赋l指定的变量,而不是输出到JSP面?nbsp;                                                                       | ?nbsp;   | ?nbsp;   |?br /> scope         | 由来指定的var属性指定的变量的作用域,有效?page,request,session,application                                                         | ?nbsp;   | ?nbsp;   |page
-----------------------------------------------------------------------------------------------------------------------------------------------

<fmt:requestEncoding>标记  讄~码方式
使用语法
<fmt:requestEncoding [value="charsetName"] />
作用{同?br /> request.setCharacterEncoding()
--------------------------------------------------------------------------------
<fmt:param>标记  讄~码方式
使用语法
1 <fmt:param value="messageParameter" />
2 <fmt:param>
  body content
  </fmt:param>
-----------------------------------------------------------------
<fmt:formatDate> 标记
使用Ҏ(gu):
<fmt:formatDate value="${today}" type="date" />
<fmt:formatDate value="${today}" dateStyle="full" />
<fmt:formatDate value="${today}" pattern="yyyy/MM/dd HH:mm:ss" />
<fmt:formatDate value="${today}" pattern="yyyy/MM/dd HH:mm:ss" var="d"/>
----------------------------------------------------------------------------
属性名     | 描述                          | ?nbsp;               |l果
value         | 要格式化的日期?| default           |2008-8-1
type          | 昄的日期格?nbsp;     | date              |2008-8-1
                 |                                   | time              |14:47:59
                 |                                   | both              |2008-8-1 14:47:59
dateStyle   | 昄的日期格?nbsp;     | short             |08-8-1
                 |                                  | medium            |2008-8-1
                 |                                    | long              |2008q???br />                  |                                     | full              |2008q???星期一
pattern       | 定义日期格式           |yyy/MM/dd HH:mm:ss |2008/08/01 14:47:59
var            | 保存值变量名            |                   |
scope        | 保存变量的scope       |                   |
-----------------------------------------------------------------------------
<fmt:formatNumber> 标记
<fmt:formatNumber value="${n}" pattern="###,###.##"/>
<fmt:formatNumber value="${n}" pattern="###,###.0000"/>
----------------------------------------------------------------------------
属性名      | 描述                          | ?nbsp;               |l果
value          | 要格式化的日期?| default           |123,456.123
type           | 昄的数据格?nbsp;     | number(数字)      |123,456.123
                  |                                   | currency(货币)    |K?23,456.123
                  |                                   | percent(癑ֈ?   |23.33%
groupingUsed| 是否分组昄       | true/false        |
pattern       | 定义数据格式           |###,###.##         |123,456.123
                  |                                    |###,###.0000       |123,456.1230
var             | 保存值变量名          |                   |
scope        | 保存变量的scope       |                   |
-----------------------------------------------------------------------------
<format>标记例子
1 建立resources.properties文g(英文)
  内容:guestbook.display.welcome=welcome to my website
2 建立resources.properties_zh_CN.properties文g(中文)
  Ҏ(gu):
  (1)在(f)时目录下建立一个(f)时文件resources_t.properties
     内容:guestbook.display.welcome=Ƣ迎大家讉K|站
  (2)在DOS下进行该临时目录,执行DOS命今
     c:\temp>native2ascii -encoding uft-8 resources_t.properties resources_zh_CN.properties
  (3){换好的文件复制到目目录?br /> 3 建立JSP面
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"  %>
fmt:bundle basename="com.tags.resources">
    <fmt:message key="guestbook.display.welcome">
    </fmt:message>
</fmt:bundle>

-----------------------------------------------------------------------------------------------------------
<sql>标签
<setDatasource>
<update>
<query>
<param>
1 导入sql的jar?br /> <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"  %>
<sql:setDataSource driver="" url="" user="" password="" var="" scope=""/>
<sql:update var="oerder" dataSource="${conn}">
 insert into BookOrder(username,zipcode,phone,creditcard,total)
 values(?,?,'88888833333','123432432423',50.00)
 <sql:param value="accp"/>
 <sql:param value="1111"/>
</sql:update>
<sql:query var="rs" dataSource="${conn}">
   select * from aa
</sql:query>
<C:forEach var="row" items="${rs.rows}">
   ${row.username}     ${row.password}
</c:forEach>



junly 2009-11-29 22:19 发表评论
]]>
jsp动作http://m.tkk7.com/ywj-316/archive/2009/11/29/304156.htmljunlyjunlySun, 29 Nov 2009 14:04:00 GMThttp://m.tkk7.com/ywj-316/archive/2009/11/29/304156.htmlhttp://m.tkk7.com/ywj-316/comments/304156.htmlhttp://m.tkk7.com/ywj-316/archive/2009/11/29/304156.html#Feedback0http://m.tkk7.com/ywj-316/comments/commentRss/304156.htmlhttp://m.tkk7.com/ywj-316/services/trackbacks/304156.html <jsp:include page="/include.jsp"></jsp:include>动作
<%@ include file="/footer.html"%>//指今
jsp:forward
 1 <jsp:forward page="/include.jsp" />
 2 <%
    RequestDispatcher rd=request.getRequestDispatcher("/imclude.jsp");
    rd.forward(request,response);
   %>
 1?l果相同

junly 2009-11-29 22:04 发表评论
]]>
javaBeanhttp://m.tkk7.com/ywj-316/archive/2009/11/29/304154.htmljunlyjunlySun, 29 Nov 2009 14:03:00 GMThttp://m.tkk7.com/ywj-316/archive/2009/11/29/304154.htmlhttp://m.tkk7.com/ywj-316/comments/304154.htmlhttp://m.tkk7.com/ywj-316/archive/2009/11/29/304154.html#Feedback0http://m.tkk7.com/ywj-316/comments/commentRss/304154.htmlhttp://m.tkk7.com/ywj-316/services/trackbacks/304154.html * 装数据
* 装业务Ҏ(gu)
<jsp:useBean/>
<jsp:useBean id="" class="" scope=""/>
class属性必L?scope默认为page
<jsp:setProperty/>
<jsp:setProperty name="user" property="*"/>
多个form属性自动匹?br /> <jsp:getProperty/>
<jsp:forward/>
<jsp:forward page="b.jsp"/>//相当于request.getRequestDispatcher
<jsp:include/>
区分大小?br />

junly 2009-11-29 22:03 发表评论
]]>
ELhttp://m.tkk7.com/ywj-316/archive/2009/11/29/304153.htmljunlyjunlySun, 29 Nov 2009 14:02:00 GMThttp://m.tkk7.com/ywj-316/archive/2009/11/29/304153.htmlhttp://m.tkk7.com/ywj-316/comments/304153.htmlhttp://m.tkk7.com/ywj-316/archive/2009/11/29/304153.html#Feedback0http://m.tkk7.com/ywj-316/comments/commentRss/304153.htmlhttp://m.tkk7.com/ywj-316/services/trackbacks/304153.html//EL  的基本用?br /> cd            | CZ                         | 对应的调用方?br /> javaBeans    | ${user.username}*    | user.getUsername()
                    | ${user["username"]}  |
                    | ${user['username']}   | sport[1]
数组            | ${sport[1]}*             |
                    | ${sport['1']}              |
                    | ${sport["1"]}             |
List              | ${address[2]}*          | address.get(2)
                    | ${address['2']}          |
                    | ${address["2"]}         |
Map             | ${phone["home"]}     | phone.get("home")
                    | ${phone['home']}      |
                    | ${phone.home}*       |
           
//EL的内|对象(与JSP有区加别Q只能在EL中用,不能用在JSP?名称不同但指同一个内容)(j)
pageContext      对应JSP中当前页面上下文的对?br /> pageScope        对应JSP中page对象
requestScope     对应JSP中request对象
sessionScope     对应JSP中session对象
applicationScope 对应JSP中application对象
param            对应面传值的对象
paramValues      对应面传来一l值的对象
header           对应面头信息的值对?br /> headerValues     对应面头信息的数组对象
<%= session.getAttribute("phone")%>
{h(hun)?
${sessionScope.phone}
cookie对应cookie对象的?br /> initParam对应讑֮的初始参数的?/p>

//讑֮JSP不用JSP EL
当前面页不?br /> <%@page isELIgnored="true"%>
整个WEB应用不用JSP EL
修改web.xml
<web-app...>
  <jsp-config>
    <jsp-property-group>
      <url-pattern>*.jsp</url-pattern>
      <el-ignored>true</el-ignored>
    </jsp-property-group>
  </jsp-config>
</web-app>
----------------------------------------------------
pageContext.setAttribute("username",null)//false
pageContext.setAttribute("username","")//false

${empty username}//判断username是否为空
---------------------------------------------------
pageContext.setAttribute("username","janly")
request.setAttribute("username","janly")
session.setAttribute("username","janly")
application.setAttribute("username","janly")

${pageScope.username}
${requestScope.username}
${sessionScope.username}
${applicationScope.username}
${username}按作用域范围找查
-----------------------------------------
web.xml
<context-param>
<param-name>repeat</param-name>
<param-value>100</param-value>
</context-param>

${initParam.repeat}
${param.username}
---------------------------------



junly 2009-11-29 22:02 发表评论
]]>
վ֩ģ壺 þĻƵ| պĻ| ĻӰĻַ8848aa| ɫAAVѲ| þùɫAVѿ| ëƬѹۿ| 91ڹӰ| ձƵһ߹ۿ| þþþѿaԿ| ѿƬ߹ۿ| 鶹˾Ʒ| Ļһҳ| | AVһϵ| ˳վ߲vr| һҳ| AVպƷþþþþ| ޲߹ۿ| պëƬһ| 2022ھƷѸƵ| xxxxƵѲֱ| ˽Ƶ75| պƷAƬ| Ļ߹ۿ| avպavӰ| baoyu777Ƶ| պƷר| þþƷ޸| Ļ| þþƷŮav鶹| Ƶ| Ů˱Ƶվ| պһ| ŷ޾Ʒ˾þԻ| VƬ߹ۿ| þ99ྫƷѹۿ| xxxxx| avƬ߹ۿ18Ů| ޳˸վ| ŷһ| Ƶ߹ۿ |