﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-小魏</title><link>http://www.blogjava.net/weikangzhen/</link><description /><language>zh-cn</language><lastBuildDate>Sun, 12 Apr 2026 07:54:51 GMT</lastBuildDate><pubDate>Sun, 12 Apr 2026 07:54:51 GMT</pubDate><ttl>60</ttl><item><title>基于nginx负载均衡的理解</title><link>http://www.blogjava.net/weikangzhen/archive/2016/08/17/431614.html</link><dc:creator>魏文甫</dc:creator><author>魏文甫</author><pubDate>Wed, 17 Aug 2016 09:03:00 GMT</pubDate><guid>http://www.blogjava.net/weikangzhen/archive/2016/08/17/431614.html</guid><wfw:comment>http://www.blogjava.net/weikangzhen/comments/431614.html</wfw:comment><comments>http://www.blogjava.net/weikangzhen/archive/2016/08/17/431614.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weikangzhen/comments/commentRss/431614.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weikangzhen/services/trackbacks/431614.html</trackback:ping><description><![CDATA[做个总结<br />linux服务器上做负载均衡<br />自己准备的:linux服务器(45.78.20.168),jdk1.7,nginx,redis,tomcat7两个,部署的项目;<br /><br />1:jdk1.7安装,两个tomcat分别端口8080,8081;部署相同的项目;启动;<br />&nbsp; &nbsp; <a href="http://45.78.20.168:8080/redis3.2/getRedis.action" target="_blank">http://45.78.20.168:8080/redis3.2/getRedis.action</a><br /><div>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://45.78.20.168:8081/redis3.2/getRedis.action" target="_blank">http://45.78.20.168:8081/redis3.2/getRedis.action<br /></a></div>2:安装nginx,添加负载的配置,安装目录下找&nbsp;<span style="line-height: 1.875; text-indent: 28px; white-space: pre-wrap;">/etc/nginx/conf.d/default.conf文件(或/etc/nginx/nginx.conf);</span>策略设置为默认轮询;<div>&nbsp;&nbsp;&nbsp;&nbsp;upstream  www.nimenhaihaoma.com  { <br />	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server   45.78.20.168:8080; <br />	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server   45.78.20.168:8081; <br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /> &nbsp;&nbsp;&nbsp;&nbsp;server{<br /> 	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen 80; <br />	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name www.nimenhaihaoma.com; <br />	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;location / { <br />		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_pass         http://www.nimenhaihaoma.com; <br />		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_set_header   Host             $host; <br />		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_set_header   X-Real-IP        $remote_addr; <br />		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for; <br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />3:配置session共享,方式很多,这里用的redis的session共享(兼容jdk版本至少1.7):<br />&nbsp; &nbsp; tomcat的lib包加<span style="line-height: 1.875; white-space: pre-wrap;">commons-pool2-2.0.jar,jedis-2.5.2.jar,tomcat-redis-session-manager1.2.jar;<br /></span>&nbsp; &nbsp; tomcat配置文件context.xml,在标签&lt;Context&gt;内添加配置:<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" /&gt;<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager" host="localhost" port="6379" database="0" maxInactiveInterval="60" /&gt;</div><br />4:项目里面区分session的代码:<br />&nbsp; &nbsp; (1):放session的接口(执行一次);<br />&nbsp; &nbsp; (2):取session数据(不断刷新),看tomcat打印信息;<br />5:效果,<a href="http://www.nimenhaihaoma.com/redis3.2/getRedis.action" target="_blank">http://www.nimenhaihaoma.com/redis3.2/getRedis.action</a>&nbsp;(狂刷session值相同)<br /><br /><br /><a href="http://www.nimenhaihaoma.com/redis3.2/getRedis.action" target="_blank"><br /></a></div><img src ="http://www.blogjava.net/weikangzhen/aggbug/431614.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weikangzhen/" target="_blank">魏文甫</a> 2016-08-17 17:03 <a href="http://www.blogjava.net/weikangzhen/archive/2016/08/17/431614.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>spring定时器的一些问题</title><link>http://www.blogjava.net/weikangzhen/archive/2015/04/25/424661.html</link><dc:creator>魏文甫</dc:creator><author>魏文甫</author><pubDate>Sat, 25 Apr 2015 03:09:00 GMT</pubDate><guid>http://www.blogjava.net/weikangzhen/archive/2015/04/25/424661.html</guid><wfw:comment>http://www.blogjava.net/weikangzhen/comments/424661.html</wfw:comment><comments>http://www.blogjava.net/weikangzhen/archive/2015/04/25/424661.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weikangzhen/comments/commentRss/424661.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weikangzhen/services/trackbacks/424661.html</trackback:ping><description><![CDATA[项目只是加载spring的几个定时任务，启动服务一直循环加载spring文件，问题的根节点：定时器类里面的service对象采取配置的方式注入，而这个定时器类的构造让我给加上了:<br />ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext*.xml");<br />myServiceImpl = context.getBean("XXXService");<br /><br />加上这段为了方便测试，在该类里写main方法测试执行，把调用写到构造里；，spring定时器配置好时间后，此处构造忘了去掉；导致启动tomcat服务一直在加载spring注入文件；<br />同理，spring注入的方式，在action里同样有这样的效果，构造方法一定注意；<img src ="http://www.blogjava.net/weikangzhen/aggbug/424661.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weikangzhen/" target="_blank">魏文甫</a> 2015-04-25 11:09 <a href="http://www.blogjava.net/weikangzhen/archive/2015/04/25/424661.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java 类是公共的，应在名为.java 的文件中声明</title><link>http://www.blogjava.net/weikangzhen/archive/2014/08/28/417463.html</link><dc:creator>魏文甫</dc:creator><author>魏文甫</author><pubDate>Thu, 28 Aug 2014 12:18:00 GMT</pubDate><guid>http://www.blogjava.net/weikangzhen/archive/2014/08/28/417463.html</guid><wfw:comment>http://www.blogjava.net/weikangzhen/comments/417463.html</wfw:comment><comments>http://www.blogjava.net/weikangzhen/archive/2014/08/28/417463.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weikangzhen/comments/commentRss/417463.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weikangzhen/services/trackbacks/417463.html</trackback:ping><description><![CDATA[是在build.xml编译的时候,包里有两个类名一样的java文件,我只是做了个备份,忘了改文件后缀,备份的文件也编译了,所以报的这个错<img src ="http://www.blogjava.net/weikangzhen/aggbug/417463.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weikangzhen/" target="_blank">魏文甫</a> 2014-08-28 20:18 <a href="http://www.blogjava.net/weikangzhen/archive/2014/08/28/417463.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>简单的添加、删除、更新索引文件中的索引</title><link>http://www.blogjava.net/weikangzhen/archive/2013/08/16/402918.html</link><dc:creator>魏文甫</dc:creator><author>魏文甫</author><pubDate>Fri, 16 Aug 2013 04:08:00 GMT</pubDate><guid>http://www.blogjava.net/weikangzhen/archive/2013/08/16/402918.html</guid><wfw:comment>http://www.blogjava.net/weikangzhen/comments/402918.html</wfw:comment><comments>http://www.blogjava.net/weikangzhen/archive/2013/08/16/402918.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weikangzhen/comments/commentRss/402918.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weikangzhen/services/trackbacks/402918.html</trackback:ping><description><![CDATA[<div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="text-align: -webkit-auto;"><strong>1，添加索引文件中的一条新的索引 &nbsp; &nbsp;&nbsp;</strong><br /></span>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="text-align: -webkit-auto;">Question addQ = new Question();</span>//新添加的一条数据,对象id在索引文件中没有<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addQ.setId("999999999");<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addQ.setQuestionname("新添加的一条数据名称");</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Analyzer sa = new SmartChineseAnalyzer(Version.LUCENE_40);</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">		</span>IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_40, sa);</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">		</span>iwc.setOpenMode(OpenMode.APPEND);</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">		</span>IndexWriter writer = null;</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">		</span>try {</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>Directory dir1 = FSDirectory.open(new File("F:\\temp"));</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>writer = new IndexWriter(dir1, iwc);</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>FieldType ft = new FieldType();</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>ft.setIndexed(true);</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>ft.setStored(true);</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>ft.setTokenized(true);</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>FieldType ft2 = new FieldType();</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>ft2.setIndexed(true);</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>ft2.setStored(true);</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>ft2.setTokenized(false);</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"></div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>Document doc = new Document();</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>doc.add(new Field("id",&nbsp;addQ.getId(), ft2));</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>doc.add(new Field("questionname", addQ.getQuestionname(), ft));</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>writer.addDocument(doc);</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>writer.close();</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">		</span>} catch (CorruptIndexException e) {</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>e.printStackTrace();</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">		</span>} catch (LockObtainFailedException e) {</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>e.printStackTrace();</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">		</span>} catch (IOException e) {</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>e.printStackTrace();</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">		</span>} finally{</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>try {</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">				</span>if(writer!=null){</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">					</span>writer.close();</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">				</span>}</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">				</span>if(sa!=null){</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">					</span>sa.close();</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">				</span>}</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>} catch (CorruptIndexException e) {</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">				</span>// TODO Auto-generated catch block</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">				</span>e.printStackTrace();</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>} catch (IOException e) {</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">				</span>// TODO Auto-generated catch block</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">				</span>e.printStackTrace();</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="white-space: pre; ">			</span>}</div><div style="orphans: 2; text-align: -webkit-auto; widows: 2;"><span style="font-family: 微软雅黑; line-height: normal; white-space: pre;">		</span><font face="微软雅黑"><span style="line-height: normal;">}</span></font><br /><font face="微软雅黑"><span style="line-height: normal;">执行完程序后，索引文件中已经添加新的索引数据。</span></font><br /><strong style="font-family: 微软雅黑; line-height: normal;">2，删除</strong><strong style="font-family: 微软雅黑; line-height: normal; text-align: -webkit-auto;">索引文件中的一条新的索引<br /></strong><font face="微软雅黑"><span style="line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Question delQ = new Question();//索引文件中有的一条数据，根据对象id删</span></font><br /><font face="微软雅黑"><span style="line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delQ.setId("1111111");</span></font><br /><font face="微软雅黑"><span style="line-height: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delQ.setQuestionname("要删除的一条数据");</span></font><br /><div style="font-family: 微软雅黑; line-height: normal;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IndexWriter writer = null;</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">		</span>Analyzer sa = new SmartChineseAnalyzer(Version.LUCENE_40);</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">		</span>IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_40, sa);</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">		</span>Directory dir1 = null;</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">		</span>try {</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">			</span>dir1 = FSDirectory.open(new File("F:\\temp"));</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">			</span>writer = new IndexWriter(dir1, iwc);</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">			</span>Term term = new Term("id", delQ.getId());</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">			</span>writer.deleteDocuments(term);</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">			</span>writer.commit();</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">			</span>writer.close();</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">		</span>} catch (CorruptIndexException e) {</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">			</span>e.printStackTrace();</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">		</span>} catch (LockObtainFailedException e) {</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">			</span>e.printStackTrace();</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">		</span>} catch (IOException e) {</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">			</span>e.printStackTrace();</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">		</span>} finally {</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">			</span>try {</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">				</span>if (writer != null) {</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">					</span>writer.close();</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">					</span>sa.close();</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">				</span>}</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">			</span>} catch (CorruptIndexException e) {</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">				</span>e.printStackTrace();</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">			</span>} catch (IOException e) {</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">				</span>e.printStackTrace();</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">			</span>}</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">		</span>}</div><div style="font-family: 微软雅黑; line-height: normal;"><span style="white-space: pre; ">		</span>System.out.println("索引删除完成");</div><font face="微软雅黑"><span style="line-height: normal;"><strong>3</strong></span></font><strong style="font-family: verdana, 'courier new'; line-height: 21px;">，更新</strong><strong style="font-family: verdana, 'courier new'; line-height: 21px;">索引文件中的一条索引<br />更新索引文件中的一条索引的理念是：先找到这条索引删除，然后再添加这条更新后的索引</strong><span style="font-family: verdana, 'courier new'; line-height: 21px;"><br /><br /></span></div><img src ="http://www.blogjava.net/weikangzhen/aggbug/402918.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weikangzhen/" target="_blank">魏文甫</a> 2013-08-16 12:08 <a href="http://www.blogjava.net/weikangzhen/archive/2013/08/16/402918.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>简单的lucene根据索引文件查询(搜索引擎)</title><link>http://www.blogjava.net/weikangzhen/archive/2013/08/12/402706.html</link><dc:creator>魏文甫</dc:creator><author>魏文甫</author><pubDate>Mon, 12 Aug 2013 09:26:00 GMT</pubDate><guid>http://www.blogjava.net/weikangzhen/archive/2013/08/12/402706.html</guid><wfw:comment>http://www.blogjava.net/weikangzhen/comments/402706.html</wfw:comment><comments>http://www.blogjava.net/weikangzhen/archive/2013/08/12/402706.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/weikangzhen/comments/commentRss/402706.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weikangzhen/services/trackbacks/402706.html</trackback:ping><description><![CDATA[<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IndexReader reader = DirectoryReader.open(FSDirectory.open(new File("F:\\temp")));// 打开索引</div><div><span style="white-space:pre">		</span>IndexSearcher searcher = new IndexSearcher(reader);</div><div><span style="white-space:pre">		</span></div><div><span style="white-space:pre">		</span>Analyzer analyzer = new SmartChineseAnalyzer(Version.LUCENE_40);</div><div><span style="white-space:pre">		</span>String[] fields = { "questionname","id" };</div><div><span style="white-space:pre">		</span>Occur[] occurs = new Occur[] { Occur.SHOULD,Occur.SHOULD };</div><div><span style="white-space:pre">		</span>Query query = &nbsp;MultiFieldQueryParser.parse(Version.LUCENE_40, "<span style="color: red;">测试 的</span>", fields,</div><div><span style="white-space:pre">				</span>occurs, analyzer);</div><div><span style="white-space:pre">		</span>TopDocs result = searcher.search(query, searcher.getIndexReader()</div><div><span style="white-space:pre">				</span>.maxDoc());</div><div><span style="white-space:pre">		</span>ScoreDoc[] hits = result.scoreDocs;</div><div><span style="white-space:pre">		</span>List&lt;Document&gt; list = new ArrayList&lt;Document&gt;();</div><div><span style="white-space:pre">		</span>for (int i = 0; i &lt;hits.length; i++) {</div><div><span style="white-space:pre">			</span>Document doc = searcher.doc(hits[i].doc);</div><div><span style="white-space:pre">			</span>list.add(doc);</div><div><span style="white-space:pre">		</span>}</div><div><span style="white-space:pre">		</span>System.out.println("搜索list的长度\t&#8594;&#8594;&#8594;&#8594;\t"+list.size());</div><div><span style="white-space:pre">		</span>for (Document document : list) {</div><div><span style="white-space:pre">			</span>System.out.println(document.getField("questionname"));</div><div><span style="white-space:pre">		</span>}</div><div><span style="white-space:pre">		</span>analyzer.close();<br /><br />注：红色字体是输入的检索条件，多个用空格隔开，找到的结果先匹配同时符合多个的结果，结果只是拿过来的document一个list集合，具体结果再解析就行了。<br /><br />结果如图：<br /><img src="http://www.blogjava.net/images/blogjava_net/weikangzhen/捕获.PNG" width="507" height="46" alt="" /></div><img src ="http://www.blogjava.net/weikangzhen/aggbug/402706.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weikangzhen/" target="_blank">魏文甫</a> 2013-08-12 17:26 <a href="http://www.blogjava.net/weikangzhen/archive/2013/08/12/402706.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>简单的lucene创建索引文件</title><link>http://www.blogjava.net/weikangzhen/archive/2013/08/12/402703.html</link><dc:creator>魏文甫</dc:creator><author>魏文甫</author><pubDate>Mon, 12 Aug 2013 08:50:00 GMT</pubDate><guid>http://www.blogjava.net/weikangzhen/archive/2013/08/12/402703.html</guid><wfw:comment>http://www.blogjava.net/weikangzhen/comments/402703.html</wfw:comment><comments>http://www.blogjava.net/weikangzhen/archive/2013/08/12/402703.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weikangzhen/comments/commentRss/402703.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weikangzhen/services/trackbacks/402703.html</trackback:ping><description><![CDATA[<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Connection conn = null;</div><div><span style="white-space:pre">		</span>Statement stat = null;</div><div><span style="white-space:pre">		</span>ResultSet rs = null;</div><div><span style="white-space:pre">		</span>Analyzer sa = new SmartChineseAnalyzer(Version.LUCENE_40);</div><div><span style="white-space:pre">		</span>IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_40, sa);</div><div><span style="white-space:pre">		</span>iwc.setOpenMode(OpenMode.CREATE);</div><div><span style="white-space:pre">		</span>Directory dir1 = FSDirectory.open(new File("F:\\temp"));</div><div><span style="white-space:pre">		</span>IndexWriter writer = new IndexWriter(dir1, iwc);</div><div><span style="white-space:pre">		</span>int numIndexed = -1;</div><div><span style="white-space:pre">		</span>FieldType ft = new FieldType();</div><div><span style="white-space:pre">		</span>ft.setIndexed(true);</div><div><span style="white-space:pre">		</span>ft.setStored(true);</div><div><span style="white-space:pre">		</span>ft.setTokenized(true);</div><div></div><div><span style="white-space:pre">		</span>FieldType ft2 = new FieldType();</div><div><span style="white-space:pre">		</span>ft2.setIndexed(true);</div><div><span style="white-space:pre">		</span>ft2.setStored(true);</div><div><span style="white-space:pre">		</span>ft2.setTokenized(false);</div><div></div><div><span style="white-space:pre">		</span>Class.forName("com.mysql.jdbc.Driver");</div><div><span style="white-space:pre">		</span>conn = (Connection) DriverManager.getConnection(</div><div><span style="white-space:pre">				</span>"jdbc:mysql:///question", "root", "root");</div><div><span style="white-space:pre">		</span>stat = (Statement) conn.createStatement();</div><div><span style="white-space:pre">		</span>rs = stat.executeQuery("select id,questionname from question");</div><div><span style="white-space:pre">		</span>List&lt;String&gt; list = new ArrayList&lt;String&gt;();</div><div><span style="white-space:pre">		</span>while (rs.next()) {</div><div><span style="white-space:pre">			</span>String id = rs.getString("questionname");</div><div><span style="white-space:pre">			</span>String questionname = rs.getString("questionname");</div><div><span style="white-space:pre">			</span>list.add(id);</div><div><span style="white-space:pre">			</span>list.add(questionname);</div><div><span style="white-space:pre">		</span>}</div><div><span style="white-space:pre">		</span>rs.close();</div><div><span style="white-space:pre">		</span>stat.close();</div><div><span style="white-space:pre">		</span>conn.close();</div><div><span style="white-space:pre">		</span></div><div><span style="white-space:pre">		</span>for (String string : list) {</div><div><span style="white-space:pre">			</span>Document doc = new Document();</div><div><span style="white-space:pre">			</span>doc.add(new Field("questionname", string, ft2));</div><div><span style="white-space:pre">			</span>writer.addDocument(doc);</div><div><span style="white-space:pre">		</span>}</div><div><span style="white-space:pre">		</span>numIndexed = writer.maxDoc();</div><div><span style="white-space:pre">		</span></div><div><span style="white-space:pre">		</span>writer.close();<br />执行完这段程序f盘多一个文件夹temp，里面就是创建好的索引文件了，然后进行根据索引文件查询<br /></div><img src ="http://www.blogjava.net/weikangzhen/aggbug/402703.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weikangzhen/" target="_blank">魏文甫</a> 2013-08-12 16:50 <a href="http://www.blogjava.net/weikangzhen/archive/2013/08/12/402703.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>简单的滑轮滚动出现"回到顶端"</title><link>http://www.blogjava.net/weikangzhen/archive/2013/08/07/402491.html</link><dc:creator>魏文甫</dc:creator><author>魏文甫</author><pubDate>Wed, 07 Aug 2013 02:35:00 GMT</pubDate><guid>http://www.blogjava.net/weikangzhen/archive/2013/08/07/402491.html</guid><wfw:comment>http://www.blogjava.net/weikangzhen/comments/402491.html</wfw:comment><comments>http://www.blogjava.net/weikangzhen/archive/2013/08/07/402491.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weikangzhen/comments/commentRss/402491.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weikangzhen/services/trackbacks/402491.html</trackback:ping><description><![CDATA[<div>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</div><div>&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;</div><div>&lt;head&gt;</div><div><span style="white-space:pre">	</span>&lt;meta http-equiv="Content-Type" content="text/html;charset=GBK" /&gt;</div><div><span style="white-space:pre">	</span>&lt;title&gt;&lt;/title&gt;</div><div><span style="white-space:pre">	</span>&lt;script type="text/javascript" src="jquery-1.8.2.js"&gt;&lt;/script&gt;</div><div><span style="white-space:pre">	</span>&lt;script type="text/javascript"&gt;</div><div><span style="white-space:pre">		</span>$(document).mousemove(function(e) {</div><div><span style="white-space:pre">			</span>var innerHeight = window.innerHeight;</div><div><span style="white-space:pre">			</span>if (e.pageY &gt; innerHeight) {</div><div><span style="white-space:pre">				</span>$("#topDiv").css("display", "block");</div><div><span style="white-space:pre">			</span>}</div><div><span style="white-space:pre">			</span>if (e.pageY &lt; innerHeight) {</div><div><span style="white-space:pre">				</span>$("#topDiv").css("display", "none");</div><div><span style="white-space:pre">			</span>}</div><div><span style="white-space:pre">		</span>});</div><div><span style="white-space:pre">		</span>$("#topIcon").mouseover(function() {</div><div><span style="white-space:pre">			</span>$("#topIcon").css("text-decoration", "none");</div><div><span style="white-space:pre">			</span>$("#topIcon").children("i").removeClass();</div><div><span style="white-space:pre">			</span>$("#topIcon").children("i").addClass("icon-chevron-up");</div><div><span style="white-space:pre">		</span>});</div><div><span style="white-space:pre">		</span>$("#topIcon").mouseout(function() {</div><div><span style="white-space:pre">			</span>$("#topIcon").children("i").removeClass();</div><div><span style="white-space:pre">			</span>$("#topIcon").children("i").addClass("icon-arrow-up");</div><div><span style="white-space:pre">		</span>});</div><div><span style="white-space:pre">	</span></div><div><span style="white-space:pre">	</span>&lt;/script&gt;</div><div><span style="white-space:pre">	</span></div><div>&lt;/head&gt;</div><div>&lt;body id="bodyId"&gt;</div><div><span style="white-space:pre">	</span>&lt;div id="topDiv"</div><div><span style="white-space:pre">		</span>style="position: fixed;right: 60px;bottom: 60px;display: none"&gt;</div><div><span style="white-space:pre">		</span>&lt;a id="topIcon" href="#bodyId" style="background-color: #aaaaaa"&gt;&lt;span</div><div><span style="white-space:pre">			</span>style="text-align: justify;display: block;text-decoration: none;width: 14px;background-color: #cccccc"&gt;回到顶端&lt;/span&gt;</div><div><span style="white-space:pre">		</span>&lt;/a&gt;</div><div><span style="white-space:pre">	</span>&lt;/div&gt;</div><div><span style="white-space:pre">	</span>&lt;h1&gt;O(&#8745;_&#8745;)O哈哈~&lt;/h1&gt;</div><div><span style="white-space:pre">	</span>&lt;h2&gt;(*^__^*) 嘻嘻&#8230;&#8230;&lt;/h2&gt;</div><div><span style="white-space:pre">	</span>&lt;h3&gt;O(&#8745;_&#8745;)O~&lt;/h3&gt;</div><div><span style="white-space:pre">	</span>&lt;h4&gt;\(^o^)/~&lt;/h4&gt;</div><div><span style="white-space:pre">	</span>&lt;h5&gt;$_$&lt;/h5&gt;</div><div><span style="white-space:pre">	</span>&lt;h6&gt;o(&#9583;&#9633;&#9584;)o&lt;/h6&gt;</div><div><span style="white-space:pre">	</span>&lt;h1&gt;O(&#8745;_&#8745;)O哈哈~&lt;/h1&gt;</div><div><span style="white-space:pre">	</span>&lt;h2&gt;(*^__^*) 嘻嘻&#8230;&#8230;&lt;/h2&gt;</div><div><span style="white-space:pre">	</span>&lt;h3&gt;O(&#8745;_&#8745;)O~&lt;/h3&gt;</div><div><span style="white-space:pre">	</span>&lt;h4&gt;\(^o^)/~&lt;/h4&gt;</div><div><span style="white-space:pre">	</span>&lt;h5&gt;$_$&lt;/h5&gt;</div><div><span style="white-space:pre">	</span>&lt;h6&gt;o(&#9583;&#9633;&#9584;)o&lt;/h6&gt;</div><div><span style="white-space:pre">	</span>&lt;h1&gt;O(&#8745;_&#8745;)O哈哈~&lt;/h1&gt;</div><div><span style="white-space:pre">	</span>&lt;h2&gt;(*^__^*) 嘻嘻&#8230;&#8230;&lt;/h2&gt;</div><div><span style="white-space:pre">	</span>&lt;h3&gt;O(&#8745;_&#8745;)O~&lt;/h3&gt;</div><div><span style="white-space:pre">	</span>&lt;h4&gt;\(^o^)/~&lt;/h4&gt;</div><div><span style="white-space:pre">	</span>&lt;h5&gt;$_$&lt;/h5&gt;</div><div><span style="white-space:pre">	</span>&lt;h6&gt;o(&#9583;&#9633;&#9584;)o&lt;/h6&gt;</div><div><span style="white-space:pre">	</span>&lt;h1&gt;O(&#8745;_&#8745;)O哈哈~&lt;/h1&gt;</div><div><span style="white-space:pre">	</span>&lt;h2&gt;(*^__^*) 嘻嘻&#8230;&#8230;&lt;/h2&gt;</div><div><span style="white-space:pre">	</span>&lt;h3&gt;O(&#8745;_&#8745;)O~&lt;/h3&gt;</div><div><span style="white-space:pre">	</span>&lt;h4&gt;\(^o^)/~&lt;/h4&gt;</div><div><span style="white-space:pre">	</span>&lt;h5&gt;$_$&lt;/h5&gt;</div><div><span style="white-space:pre">	</span>&lt;h6&gt;o(&#9583;&#9633;&#9584;)o&lt;/h6&gt;</div><div><span style="white-space:pre">	</span>&lt;h1&gt;O(&#8745;_&#8745;)O哈哈~&lt;/h1&gt;</div><div><span style="white-space:pre">	</span>&lt;h2&gt;(*^__^*) 嘻嘻&#8230;&#8230;&lt;/h2&gt;</div><div><span style="white-space:pre">	</span>&lt;h3&gt;O(&#8745;_&#8745;)O~&lt;/h3&gt;</div><div><span style="white-space:pre">	</span>&lt;h4&gt;\(^o^)/~&lt;/h4&gt;</div><div><span style="white-space:pre">	</span>&lt;h5&gt;$_$&lt;/h5&gt;</div><div><span style="white-space:pre">	</span>&lt;h6&gt;o(&#9583;&#9633;&#9584;)o&lt;/h6&gt;</div><div><span style="white-space:pre">	</span>&lt;h1&gt;O(&#8745;_&#8745;)O哈哈~&lt;/h1&gt;</div><div><span style="white-space:pre">	</span>&lt;h2&gt;(*^__^*) 嘻嘻&#8230;&#8230;&lt;/h2&gt;</div><div><span style="white-space:pre">	</span>&lt;h3&gt;O(&#8745;_&#8745;)O~&lt;/h3&gt;</div><div><span style="white-space:pre">	</span>&lt;h4&gt;\(^o^)/~&lt;/h4&gt;</div><div><span style="white-space:pre">	</span>&lt;h5&gt;$_$&lt;/h5&gt;</div><div><span style="white-space:pre">	</span>&lt;h6&gt;o(&#9583;&#9633;&#9584;)o&lt;/h6&gt;</div><div><span style="white-space:pre">	</span>&lt;h1&gt;O(&#8745;_&#8745;)O哈哈~&lt;/h1&gt;</div><div><span style="white-space:pre">	</span>&lt;h2&gt;(*^__^*) 嘻嘻&#8230;&#8230;&lt;/h2&gt;</div><div><span style="white-space:pre">	</span>&lt;h3&gt;O(&#8745;_&#8745;)O~&lt;/h3&gt;</div><div><span style="white-space:pre">	</span>&lt;h4&gt;\(^o^)/~&lt;/h4&gt;</div><div><span style="white-space:pre">	</span>&lt;h5&gt;$_$&lt;/h5&gt;</div><div><span style="white-space:pre">	</span>&lt;h6&gt;o(&#9583;&#9633;&#9584;)o&lt;/h6&gt;</div><div><span style="white-space:pre">	</span>&lt;h1&gt;O(&#8745;_&#8745;)O哈哈~&lt;/h1&gt;</div><div><span style="white-space:pre">	</span>&lt;h2&gt;(*^__^*) 嘻嘻&#8230;&#8230;&lt;/h2&gt;</div><div><span style="white-space:pre">	</span>&lt;h3&gt;O(&#8745;_&#8745;)O~&lt;/h3&gt;</div><div><span style="white-space:pre">	</span>&lt;h4&gt;\(^o^)/~&lt;/h4&gt;</div><div><span style="white-space:pre">	</span>&lt;h5&gt;$_$&lt;/h5&gt;</div><div><span style="white-space:pre">	</span>&lt;h6&gt;o(&#9583;&#9633;&#9584;)o&lt;/h6&gt;</div><div><span style="white-space:pre">	</span></div><div><span style="white-space:pre">	</span></div><div>&lt;/body&gt;</div><div>&lt;/html&gt;</div><img src ="http://www.blogjava.net/weikangzhen/aggbug/402491.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weikangzhen/" target="_blank">魏文甫</a> 2013-08-07 10:35 <a href="http://www.blogjava.net/weikangzhen/archive/2013/08/07/402491.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>求单一登陆和单点登陆的思路及核心代码？？？</title><link>http://www.blogjava.net/weikangzhen/archive/2013/08/07/402489.html</link><dc:creator>魏文甫</dc:creator><author>魏文甫</author><pubDate>Wed, 07 Aug 2013 01:56:00 GMT</pubDate><guid>http://www.blogjava.net/weikangzhen/archive/2013/08/07/402489.html</guid><wfw:comment>http://www.blogjava.net/weikangzhen/comments/402489.html</wfw:comment><comments>http://www.blogjava.net/weikangzhen/archive/2013/08/07/402489.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weikangzhen/comments/commentRss/402489.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weikangzhen/services/trackbacks/402489.html</trackback:ping><description><![CDATA[<div>求单一登陆和单点登陆的思路及核心代码？？？</div><img src ="http://www.blogjava.net/weikangzhen/aggbug/402489.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weikangzhen/" target="_blank">魏文甫</a> 2013-08-07 09:56 <a href="http://www.blogjava.net/weikangzhen/archive/2013/08/07/402489.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>html中中文正则表达式不对的问题</title><link>http://www.blogjava.net/weikangzhen/archive/2013/07/29/402111.html</link><dc:creator>魏文甫</dc:creator><author>魏文甫</author><pubDate>Mon, 29 Jul 2013 07:56:00 GMT</pubDate><guid>http://www.blogjava.net/weikangzhen/archive/2013/07/29/402111.html</guid><wfw:comment>http://www.blogjava.net/weikangzhen/comments/402111.html</wfw:comment><comments>http://www.blogjava.net/weikangzhen/archive/2013/07/29/402111.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weikangzhen/comments/commentRss/402111.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weikangzhen/services/trackbacks/402111.html</trackback:ping><description><![CDATA[<span style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">html中中文正则表达式不对的问题</span>&nbsp;<br /><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">中文的正则表达式：var reg = /^[\u4e00-\u9fa5]$/;(一个中文字符)</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;">放在html中可能出现的问题有：</div><div style="font-family: 微软雅黑; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2;"><div>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;</div><div>&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"&gt;</div><div>&lt;head&gt;</div><div><span style="color: #0000ff; white-space: pre; ">	</span>&lt;meta http-equiv="Content-Type" content="text/html;charset=<strong style="color: red;">UTF-8</strong>" /&gt;</div><div><span style="white-space: pre; ">	</span>&lt;title&gt;&lt;/title&gt;</div><div>&lt;/head&gt;</div><div>&lt;body&gt;</div><div><span style="white-space: pre; ">	</span>&lt;script type="text/javascript"&gt;</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var reg0 = /^[\u4e00-\u9fa5]$/;</div><div><span style="color: #0000ff; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #000000;">alert(reg0.test("看"));</span></div><div><span style="white-space: pre; ">	</span>&lt;/script&gt;</div><div>&lt;/body&gt;</div><div>&lt;/html&gt;<br />本页编码为UTF-8时出现的结果可能是错误的，<br />所以出现此类情况，编码格式改为gb2312(红色标注的编码改为gb2312)</div></div><img src ="http://www.blogjava.net/weikangzhen/aggbug/402111.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weikangzhen/" target="_blank">魏文甫</a> 2013-07-29 15:56 <a href="http://www.blogjava.net/weikangzhen/archive/2013/07/29/402111.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>将一个带格式的excel表内容(带格式)写入一个与之有相同列的excel表格中(追加写)</title><link>http://www.blogjava.net/weikangzhen/archive/2013/07/19/401768.html</link><dc:creator>魏文甫</dc:creator><author>魏文甫</author><pubDate>Fri, 19 Jul 2013 10:02:00 GMT</pubDate><guid>http://www.blogjava.net/weikangzhen/archive/2013/07/19/401768.html</guid><wfw:comment>http://www.blogjava.net/weikangzhen/comments/401768.html</wfw:comment><comments>http://www.blogjava.net/weikangzhen/archive/2013/07/19/401768.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/weikangzhen/comments/commentRss/401768.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/weikangzhen/services/trackbacks/401768.html</trackback:ping><description><![CDATA[
简单的代码:<br /><div>public static void main(String[] args) {</div><div><span style="white-space: pre;">		</span>try {</div><div><span style="white-space: pre;">			</span>File allfile = new File("f:\\excel\\total.xlsx");</div><div><span style="white-space: pre;">			</span>File file2 = new File("f:\\excel\\xxxxxx.xlsx");</div><div><span style="white-space: pre;">			</span></div><div><span style="white-space: pre;">			</span>XSSFWorkbook h = new XSSFWorkbook(new FileInputStream(allfile));</div><div><span style="white-space: pre;">			</span>XSSFSheet x = h.getSheetAt(0);</div><div><span style="white-space: pre;">			</span>XSSFWorkbook hssfWorkbook = new XSSFWorkbook(new FileInputStream(file2));</div><div><span style="white-space: pre;">			</span>XSSFSheet hssfSheet = hssfWorkbook.getSheetAt(0);</div><div><span style="white-space: pre;">			</span></div><div><span style="white-space: pre;">			</span>int ii = hssfSheet.getLastRowNum();//读取的表格行数</div><div><span style="white-space: pre;">			</span>System.out.println(ii);</div><div><span style="white-space: pre;">			</span>FileOutputStream out_ = new FileOutputStream(allfile);</div><div><span style="white-space: pre;">			</span>for (int i = 0; i &lt; ii; i++) {</div><div><span style="white-space: pre;">				</span>XSSFRow lastRow = x.createRow(x.getLastRowNum()+1);</div><div><span style="white-space: pre;">				</span>XSSFRow xssfRow = hssfSheet.getRow(i);</div><div><span style="white-space: pre;">				</span></div><div><span style="white-space: pre;">				</span>XSSFCell xssfCell0 = xssfRow.getCell(0);</div><div><span style="white-space: pre;">				</span>CellStyle cellStyle0 = xssfCell0.getCellStyle();</div><div><span style="white-space: pre;">				</span>CellStyle newStyle0 = h.createCellStyle();</div><div><span style="white-space: pre;">				</span>newStyle0.cloneStyleFrom(cellStyle0);</div><div><span style="white-space: pre;">				</span>XSSFCell xssfCell0_ = lastRow.createCell(0);</div><div><span style="white-space: pre;">				</span>xssfCell0_.setCellStyle(newStyle0);</div><div><span style="white-space: pre;">				</span>xssfCell0_.setCellValue(xssfCell0.toString());</div><div><span style="white-space: pre;">				</span></div><div><span style="white-space: pre;">				</span>XSSFCell xssfCell1 = xssfRow.getCell(1);</div><div><span style="white-space: pre;">				</span>CellStyle cellStyle1 = xssfCell1.getCellStyle();</div><div><span style="white-space: pre;">				</span>CellStyle newStyle1 = h.createCellStyle();</div><div><span style="white-space: pre;">				</span>newStyle1.cloneStyleFrom(cellStyle1);</div><div><span style="white-space: pre;">				</span>XSSFCell xssfCell1_ = lastRow.createCell(1);</div><div><span style="white-space: pre;">				</span>xssfCell1_.setCellStyle(newStyle1);</div><div><span style="white-space: pre;">				</span>xssfCell1_.setCellValue(xssfCell1.toString());</div><div><span style="white-space: pre;">				</span></div><div><span style="white-space: pre;">				</span>XSSFCell xssfCell2 = xssfRow.getCell(2);</div><div><span style="white-space: pre;">				</span>CellStyle cellStyle2 = xssfCell2.getCellStyle();</div><div><span style="white-space: pre;">				</span>CellStyle newStyle2 = h.createCellStyle();</div><div><span style="white-space: pre;">				</span>newStyle2.cloneStyleFrom(cellStyle2);</div><div><span style="white-space: pre;">				</span>XSSFCell xssfCell2_ = lastRow.createCell(2);</div><div><span style="white-space: pre;">				</span>xssfCell2_.setCellStyle(newStyle2);</div><div><span style="white-space: pre;">				</span>xssfCell2_.setCellValue(xssfCell2.toString());</div><div><span style="white-space: pre;">				</span></div><div><span style="white-space: pre;">				</span>XSSFCell xssfCell3 = xssfRow.getCell(3);</div><div><span style="white-space: pre;">				</span>CellStyle cellStyle3 = xssfCell3.getCellStyle();</div><div><span style="white-space: pre;">				</span>CellStyle newStyle3 = h.createCellStyle();</div><div><span style="white-space: pre;">				</span>newStyle3.cloneStyleFrom(cellStyle3);</div><div><span style="white-space: pre;">				</span>XSSFCell xssfCell3_ = lastRow.createCell(3);</div><div><span style="white-space: pre;">				</span>xssfCell3_.setCellStyle(newStyle3);</div><div><span style="white-space: pre;">				</span>xssfCell3_.setCellValue(xssfCell3.toString());</div><div><span style="white-space: pre;">				</span></div><div><span style="white-space: pre;">				</span>XSSFCell xssfCell4 = xssfRow.getCell(4);</div><div><span style="white-space: pre;">				</span>CellStyle cellStyle4 = xssfCell4.getCellStyle();</div><div><span style="white-space: pre;">				</span>CellStyle newStyle4 = h.createCellStyle();</div><div><span style="white-space: pre;">				</span>newStyle4.cloneStyleFrom(cellStyle4);</div><div><span style="white-space: pre;">				</span>XSSFCell xssfCell4_ = lastRow.createCell(4);</div><div><span style="white-space: pre;">				</span>xssfCell4_.setCellStyle(newStyle4);</div><div><span style="white-space: pre;">				</span>xssfCell4_.setCellValue(xssfCell4.toString().toString());</div><div><span style="white-space: pre;">			</span>}</div><div><span style="white-space: pre;">			</span>h.write(out_);</div><div><span style="white-space: pre;">			</span>out_.flush();</div><div><span style="white-space: pre;">			</span>out_.close();</div><div><span style="white-space: pre;">		</span>} catch (FileNotFoundException e) {</div><div><span style="white-space: pre;">			</span>// TODO Auto-generated catch block</div><div><span style="white-space: pre;">			</span>e.printStackTrace();</div><div><span style="white-space: pre;">		</span>} catch (IOException e) {</div><div><span style="white-space: pre;">			</span>// TODO Auto-generated catch block</div><div><span style="white-space: pre;">			</span>e.printStackTrace();</div><div><span style="white-space: pre;">		</span>}<br />}</div> 
<img src ="http://www.blogjava.net/weikangzhen/aggbug/401768.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/weikangzhen/" target="_blank">魏文甫</a> 2013-07-19 18:02 <a href="http://www.blogjava.net/weikangzhen/archive/2013/07/19/401768.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>