??xml version="1.0" encoding="utf-8" standalone="yes"?>一区二区成人,国模精品娜娜一二三区,亚洲国产精品精华液网站http://www.aygfsteel.com/gjhuai/上善若水Q仁恕蝲?/description>zh-cnFri, 20 Jun 2025 01:07:02 GMTFri, 20 Jun 2025 01:07:02 GMT60SpringMVC 2.5 的HelloWorldhttp://www.aygfsteel.com/gjhuai/archive/2008/09/27/231492.html水仁?/dc:creator>水仁?/author>Sat, 27 Sep 2008 06:31:00 GMThttp://www.aygfsteel.com/gjhuai/archive/2008/09/27/231492.htmlhttp://www.aygfsteel.com/gjhuai/comments/231492.htmlhttp://www.aygfsteel.com/gjhuai/archive/2008/09/27/231492.html#Feedback1http://www.aygfsteel.com/gjhuai/comments/commentRss/231492.htmlhttp://www.aygfsteel.com/gjhuai/services/trackbacks/231492.html
package springmvc.one.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/hellOne.act")
public class HelloOneAction { 

@RequestMapping
public String handleRequest(String user,Model model) { 
System.out.println("用户名:"+user); //GET/POST的入?br /> model.addAttribute("user", user); //通过Sessionq回到界面的出参
model.addAttribute("helloWord", "Hello");

return "hellouser";

}


再写一个JSP面hellouser.jspQ此面攑֜ WEB-INF/jsp 目录下,代码如下Q?br />
<html> 
<head><title>HelloPage</title></head> 
<body> 
Test this sample!
<H1> ${helloWord}, ${user}!</H2> 
</body>
</html>


接着看看web.xml的配|?br />
<?xml version="1.0" encoding="ISO-8859-1"?> 

<web-app version="2.4" 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-app_2_4.xsd">

<description>Spring 2.5 App</description> 
<display-name>Spring App Examples</display-name> 

<servlet> 
<servlet-name>annomvc</servlet-name> 
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup> 
</servlet> 

<servlet-mapping> 
<servlet-name>annomvc</servlet-name> 
<url-pattern>*.act</url-pattern> 
</servlet-mapping> 

</web-app>


最后就是,annomvc.xml 文g了?br />
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">

<context:component-scan base-package="springmvc.one.web"/>

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp"/>

</beans>


好了Q见一个Tomcat工程Q在 tomcat 中运行,讉K下面q接Q就可以q行了?br />
http://localhost:8080/TOMCAT-PROJECT/hellOne.act?user=gjhuai



]]>
[专业]JS一些知?0806081757http://www.aygfsteel.com/gjhuai/archive/2008/06/08/206692.html水仁?/dc:creator>水仁?/author>Sun, 08 Jun 2008 09:58:00 GMThttp://www.aygfsteel.com/gjhuai/archive/2008/06/08/206692.htmlhttp://www.aygfsteel.com/gjhuai/comments/206692.htmlhttp://www.aygfsteel.com/gjhuai/archive/2008/06/08/206692.html#Feedback0http://www.aygfsteel.com/gjhuai/comments/commentRss/206692.htmlhttp://www.aygfsteel.com/gjhuai/services/trackbacks/206692.html JS的日期加减函敎ͼ

function dateAdd(date,dayNum){
var a = date.valueOf();
a = a + dayNum * 24 * 60 * 60 * 1000;
a = new Date(a);
return a;
}


JS把字W串装蝲到DOM对象Q?br> var doc = new ActiveXObject("MSxml2.DOMDocument");
doc.loadXML( xmlStr);


当JS的正则表辑ּ的pattern需要动态构造时Q需要用RegExpc:
patt=new RegExp(today.replace(/\-/g,"\\-")+"((.|\n|\r|\t)+)"+yesterday.replace(/\-/g,"\\-"),"gm");
//patt=new RegExp("2008\-5\-26((.|\n)+)2008\-5\-25","gm");
h = h.replace(patt,yesterday);
而不能?dd/gm之类单的pattern






]]>
[专业]Python读gbk~码的xml问题-0806072220http://www.aygfsteel.com/gjhuai/archive/2008/06/07/206597.html水仁?/dc:creator>水仁?/author>Sat, 07 Jun 2008 14:22:00 GMThttp://www.aygfsteel.com/gjhuai/archive/2008/06/07/206597.htmlhttp://www.aygfsteel.com/gjhuai/comments/206597.htmlhttp://www.aygfsteel.com/gjhuai/archive/2008/06/07/206597.html#Feedback0http://www.aygfsteel.com/gjhuai/comments/commentRss/206597.htmlhttp://www.aygfsteel.com/gjhuai/services/trackbacks/206597.html Python读xmlӞ如果~码不是utf-8或utf-16Q就出错Q如下:


...

解析q个xml文g代码如下Q?
from xml.dom import minidom
f = minidom.parse('f:\\temp\\protocol.xml')
print f.toxml()

出现q个错误Q?br> xml.parsers.expat.ExpatError: unknown encoding:


解决办法Q?

׃xml协会规定Q所有xml解析器均需要支持utf-8和utf-16两种~码而不要求别的~码Q所以我估计python提供的xml处理模块是不支持gb2312的。而windows下的文gQ大部分均ؓgb2312~码的,因此处理的时候,׃带来不方便的地方?

?Q利用UltraEdit{工Pxml文g转换成UTF-8的,然后encoding="utf-8"卛_
转换工具如果没有Q用python可以单写一个,比如
Q以下代码{? http://tenyears.cn/?cat=6 Q?
Q-Q-Q-Q-Q-
# -*- coding: mbcs -*-
import codecs
f = codecs.open(‘D:\\normal.txt? ‘rb? ‘mbcs?
text = f.read().encode(‘utf-8?
f.close
f = open(‘d:\\utf8.txt? ‘wb?
f.write(text)
f.close()
print text.decode(‘utf-8?.encode(‘gb2312?
Q-Q-Q-Q-Q-Q-Q-Q-Q?

?Qxml文g里面不要写入encodingQ保持ؓgb2312本地~码Q然后程序解析的时候,采用语句
unicode(file('f:\\temp\\a.txt', 'r', 'gb2312').read(),'gb2312').encode('utf-8')
整个文件{成utf-8? String 来处理,处理l束后,利用
unicode(string,'utf-8').encode('gb2312')
换成本地的gb码,再将l果写回文g?

另外Qpython2.4的普通函数处理字W串的时候,好像已经支持各种~码了?br>



]]>
[专业]代码阅读的经?0806072109http://www.aygfsteel.com/gjhuai/archive/2008/06/07/206586.html水仁?/dc:creator>水仁?/author>Sat, 07 Jun 2008 13:11:00 GMThttp://www.aygfsteel.com/gjhuai/archive/2008/06/07/206586.htmlhttp://www.aygfsteel.com/gjhuai/comments/206586.htmlhttp://www.aygfsteel.com/gjhuai/archive/2008/06/07/206586.html#Feedback0http://www.aygfsteel.com/gjhuai/comments/commentRss/206586.htmlhttp://www.aygfsteel.com/gjhuai/services/trackbacks/206586.html ׃工作上的原因Q我不得不看大量别h写的代码,q是一件很痛苦的事,其是看既少文档注释,又无良好命名和结构的代码.

有本书叫Code Reading,中文译作代码阅读Ҏ与实? 单浏览了一遍电子文? 感觉q是隔靴搔痒, Ҏ高代码阅L率ƈ无太大的帮助. 自己感觉q是以下Ҏ有些帮助:
1. 把对代码阅读的认识用W或wikiC? 最好根据功能结构分c?可画些辅助理解的框图或思维导图
2. 利用UML工具反向生成些类?包图, q可自己动手M些流E图,时序囑֒协作?br> 3. 利用调试工具,通过设断?单步调试,设观察哨{手D늜看到底它是怎么q行?br> 4. 写一些简单的试E序,通过断言,日志来验证自q判断
5. 如有可能,和代码的原作者或其他l护者一起做Code Review




]]>
Spring 集成试http://www.aygfsteel.com/gjhuai/archive/2008/01/13/175030.html水仁?/dc:creator>水仁?/author>Sun, 13 Jan 2008 13:57:00 GMThttp://www.aygfsteel.com/gjhuai/archive/2008/01/13/175030.htmlhttp://www.aygfsteel.com/gjhuai/comments/175030.htmlhttp://www.aygfsteel.com/gjhuai/archive/2008/01/13/175030.html#Feedback0http://www.aygfsteel.com/gjhuai/comments/commentRss/175030.htmlhttp://www.aygfsteel.com/gjhuai/services/trackbacks/175030.html8.3.1. Context理和缓?/h3>
Spring 中的?spring-mock.jar 为集成测试提供了一的支持。所有相关的API在包 org.springframework.test 中,它们不依赖于M应用服务器或者其他部|环境?br>
test包里的各U抽象类提供了如下的功能Q?br>
  • 各测试案例执行期间的Spring IoC容器~存?/li>
  • 试fixture自n的依赖注入?/li>
  • 适合集成试的事务管理?/li>
  • l承而来的对试有用的各U实例变量?/li>

test包对加蝲的Context提供~存Q缓存功能是通过 AbstractDependencyInjectionSpringContextTests cȝ一个方法(如下Q实现的Q此Ҏ提供contexts xml的位|,且实现这个方法的cdL供一个包含XML配置文g位置数组。缺省情况下Q一旦加载后Q这些配|将被所有的试案例重用?br>
protected abstract String[] getConfigLocations();

当配|环境受到破坏,AbstractDependencyInjectionSpringContextTests ?setDirty() Ҏ可以用来重新加蝲配置Qƈ在执行下一个测试案例前重徏application context?br>

8.3.2. 试fixture的依赖注?/h3>AbstractDependencyInjectionSpringContextTests cd从getConfigLocations()Ҏ指定的配|文件中自动查找你要试的类Q?q过Setter注入该类的实例?br>
单例?br>
public class HibernateTitleDaoTests extends AbstractDependencyInjectionSpringContextTests {

// 被测试类的实例将被(自动的)依赖注入
private HibernateTitleDao titleDao;

// 一个用来实?titleDao'实例变量依赖注入的setterҎ
public void setTitleDao (HibernateTitleDao titleDao) {
this.titleDao = titleDao;
}

public void testLoadTitle() throws Exception {
Title title = this.titleDao.loadTitle(new Long10));
assertNotNull(title);
}

//指定Spring配置文g加蝲q个fixture
protected String[] getConfigLocations() {
return new String[] { "classpath:com/foo/daos.xml" };
}

}

getConfigLocations() 使用的是 Ҏcd的自动装?/font>Qautowire byTypeQ来注入的,所以如果你有多个bean都定义ؓ一个类型,则对q些bean你不能用q个Ҏ。在q种情况下你要?applicationContext 实例变量Qƈ且?getBean() 来进行显式查找?br>
如果你的试案例不用依赖注入,只要不定义Q何settersҎ卛_Q?或者你可以l承 org.springframework.test.AbstractSpringContextTests c,它只包括用来加蝲Spring Context的便利方法,q且在测试fixture中不q行依赖注入?br>

8.3.3. 事务理

试Ҏ久存储的数据会有改动。类 AbstractTransactionalDataSourceSpringContextTests 在缺省情况下Q对每一个测试案例,他们创徏q且回滚一个事务。所以用这个类׃用担心数据被修改Q它依赖于Application Context中定义的一个bean PlatformTransactionManager?br>
如果你确实想在测试时修改数据Q可以用q个cȝ setComplete() ҎQ这提交而不是回滚事务。另外, endTransaction() Ҏ可以在测试结束前中止事务?br>

8.3.4. 方便的变?/h3>AbstractDependencyInjectionSpringContextTests cL供了两个保护属性性实例变量:

  • applicationContext (a ConfigurableApplicationContext): 可以利用它进行显式bean查找Q或者作Z个整体来试q个Context的状态?/li>
  • jdbcTemplate Q?对确定数据状态的查询很有用?/li>

8.3.5. CZ

Spring的PetClinic实例展示了这些测试超cȝ用法

public abstract class AbstractClinicTests extends AbstractTransactionalDataSourceSpringContextTests {

protected Clinic clinic;

public void setClinic(Clinic clinic) {
this.clinic = clinic;
}

public void testGetVets() {
Collection vets = this.clinic.getVets();
assertEquals('JDBC query must show the same number of vets'Q?br> jdbcTemplate.queryForInt('SELECT COUNT(0) FROM VETS')Q?
vets.size());
Vet v1 = (Vet) EntityUtils.getById(vetsQ?Vet.classQ?2);
assertEquals('Leary'Q?v1.getLastName());
assertEquals(1Q?v1.getNrOfSpecialties());
assertEquals('radiology'Q?((Specialty) v1.getSpecialties().get(0)).getName());
Vet v2 = (Vet) EntityUtils.getById(vetsQ?Vet.classQ?3);
assertEquals('Douglas'Q?v2.getLastName());
assertEquals(2Q?v2.getNrOfSpecialties());
assertEquals('dentistry'Q?((Specialty) v2.getSpecialties().get(0)).getName());
assertEquals('surgery'Q?((Specialty) v2.getSpecialties().get(1)).getName());
}

JdbcTemplate 变量用于验证被测试的代码是否正确。JdbcTemplate 让测试更严密Q且减少了对试数据的依赖。例如,可以在不中止试的情况下在数据库里增加额外的数据行?br>
PetClinic应用支持四种数据讉K技术-QJDBC、Hibernate、TopLink和JPA Q因?AbstractClinicTests cM指定Context位置Q这个操作在子类中实玎ͼ

例如Q用Hibernate实现的PetClinic试包含如下ҎQ?br>
public class HibernateClinicTests extends AbstractClinicTests {

protected String[] getConfigLocations() {
return new String[] {
'/org/springframework/samples/petclinic/hibernate/applicationContext-hibernate.xml'
};
}
}

8.3.6. q行集成试

集成试比单元测试更依赖于测试环境,它是试的一个补充,而不是代替单元测试的。这U依赖主要指完整数据模型的数据库。也可以通过DbUnit或者数据库工具来导入测试数据?


]]>Sentences01http://www.aygfsteel.com/gjhuai/archive/2008/01/07/173225.html水仁?/dc:creator>水仁?/author>Mon, 07 Jan 2008 00:23:00 GMThttp://www.aygfsteel.com/gjhuai/archive/2008/01/07/173225.htmlhttp://www.aygfsteel.com/gjhuai/comments/173225.htmlhttp://www.aygfsteel.com/gjhuai/archive/2008/01/07/173225.html#Feedback0http://www.aygfsteel.com/gjhuai/comments/commentRss/173225.htmlhttp://www.aygfsteel.com/gjhuai/services/trackbacks/173225.html(1) 最高 + 名词 + that + 主词 + have ever seen /known /heard /had /read)
Helen is the most beautiful girl that I have ever seen.
u是我所看过最丽的女孩?BR>Mr. Zhang is the kindest teacher that I have ever had.
张老师是我曄遇到最仁慈的教师?BR>
(2) Nothing is + 比较U?than to + V
Nothing is more important than to receive education.
没有比接受教育更重要的事?BR>
(3) ... cannot emphasize the importance of ... too much.Q再怎么...的重要性也不ؓq。)
We cannot emphasize the importance of protecting our eyes too much.
我们再怎么保护眼睛的重要性也不ؓq?BR>
(4) There is no denying /doubt that从句 Q不可否认的.../毫无疑问?..Q?BR>There is no denying that the qualities of our living have gone from bad to worse.
不可否认的,我们的生zd质已l每冉|下?BR>There is no doubt that our educational system leaves something to be desired.
毫无疑问的我们的教育制度令h不满意?BR>
(5) It is universally acknowledged that从句 Q全世界都知?..Q?BR>It is universally acknowledged that trees are indispensable to us.
全世界都知道树木Ҏ们是不可或缺的?BR>
(6)、An advantage of ... is that从句 Q?..的优Ҏ...Q?BR>An advantage of using the solar energy is that it won't create (produce) any pollution.
使用太阳能的优点是它不会刉Q何污染?BR>
(7) The reason why定语从句 ... is that + 句子 Q?..的原因是...Q?BR>The reason why we have to grow trees is that they can provide us with fresh air.
The reason why we have to grow trees is that they can supply fresh air for us.
我们必须U树的原因是它们能供应我们新鲜的I气?BR>
(8) So + 形容?+ be + 主词 + that从句 Q如?..以致?..Q?BR>So precious is time that we can't afford to waste it.
旉是如此珍贵,我们l不h费它?BR>
(9) Adj. + as + 主词 + be, S + V ... Q虽?..Q?BR>Rich as our country is, the qualities of our living are by no means satisfactory.
{by no means = in no way = on no account 一点也不}
虽然我们的国家富有,我们的生zd质绝对oZ满意?BR>
(10) 比较U?+ S + V, 比较U?+ S + V
The harder you work, the more progress you make.
你愈努力Q你愈进步?BR>The more books we read,the more learned we become.
我们书读愈多Q我们愈有学问?BR>
(11) By +Ving, ... can ... Q借着.. , ..能够..Q?BR>By taking exercise, we can always stay healthy.
借着做运动,我们能够始终保持健康?BR>
(12) ... enable + 受词 + to + V Q?.?.能够..Q?BR>Listening to music enable us to feel relaxed.
听音乐我们能够感觉L?BR>
(13) On no account can we + V ... Q我们绝对不?..Q?BR>On no account can we ignore the value of knowledge.
我们l对不能忽略知识的h倹{?BR>
(14) It is time + S + q去?Q该?..的时候了Q?BR>It is time the authorities concerned took proper steps to solve the traffic problems.
该是有关当局采取适当的措施来解决交通问题的时候了?BR>

(15) Those who ... Q?..的h...Q?BR>Those who violate traffic regulations should be punished.
q反交通规定的人应该受处罚?BR>
(16) There is no one but ... Q没有h?..Q?BR>There is no one but longs to go to college.
没有Z渴望上大学。{long v.渴望}

(17) be + forced /compelled /obliged + to do Q不得不...Q?BR>Since the examination is around the corner, I am compelled to give up doing sports.
既然考试q在眉睫Q我不得不放弃做q动?BR>
(18) It is conceivable /obvious /apparent that从句 Q可惌知?/明显?/昄的)
It is conceivable that knowledge plays an important role in our life.
可想而知Q知识在我们的一生中扮演一个重要的角色?BR>
(19) That is the reason why ... Q那是...的原因)
Summer is sultry. That is the reason why I don't like it.
夏天很燠热。那是我不喜欢它的原因?BR>
(20) For the past + 旉QS + 现在完成?. Q过?..q来Q?..一?..Q?BR>For the past two years, I have been busy preparing for the examination.
q去两年来,我一直忙着准备考试?BR>
(21) Since + S + q去式,S + 现在完成式?BR>Since he went to senior high school, he has worked very hard.
自从他上高中Q他一直很用功?BR>
(22) It pays to + V ... Q?..是值得的。)
It pays to help others.
帮助别h是值得的?BR>
(23) be based on Q以...为基Q?BR>The progress of thee society is based on harmony.
C会的进步是以和谐ؓ基础的?BR>
(24) Spare no effort to + V Q不遗余力的Q?BR>We should spare no effort to beautify our environment.
我们应该不遗余力的美化我们的环境?BR>
(25) bring home to + ?+ ?Q让...明白...事)
We should bring home to people the value of working hard.
我们应该让h们明白努力的价倹{?BR>
(26) be closely related to ... Q与...息息相关Q?BR>Taking exercise is closely related to health.
做运动与健康息息相关?BR>
(27) Get into the habit of + Ving = make it a rule to + V Q养?..的习惯)
We should get into the habit of keeping good hours.
我们应该L早睡早v的习惯?BR>
(28) [Due to | Owing to | Thanks to] + N/Ving, ... Q因?..Q?BR>Thanks to his encouragement, I finally realized my dream.
因ؓ他的鼓励Q我l于实现我的梦想?BR>
(29) [What a + adj. + sth. | How + adj. + sth.] + it is to do sth.Q多?..Q)
What an important thing it is to keep our promise!
How important a thing it is to keep our promise!
遵守是多么重要的事!

(30) leave much to be desired QoZ满意Q?BR>The condition of our traffic leaves much to be desired.
我们的交通状况oZ满意?BR>
(31) have a great influence on ... Q对...有很大的影响Q?BR>Smoking has a great influence on our health.
抽烟Ҏ们的健康有很大的影响?BR>
(32) do good to Q对...有益Q,do harm to Q对...有害Q?BR>Reading does good to our mind.
M对心灉|益?BR>Overwork does harm to health.
工作q度对健h実?BR>
(33) pose a great threat to ~~ Q对...造成一大威胁)
Pollution poses a great threat to our existence.
污染Ҏ们的生存造成一大威胁?BR>
(34) do one's [utmost | best] to do sth.Q尽全力?..Q?BR>We should do our utmost to achieve our goal in life.
我们应尽全力去达成我们的人生目标?BR>
(35) would rather /sooner + V + than + V + (宁愿...也不)
They would rather go fishing than stay at home.
他们宁愿去钓|也不愿待在家里?
She would sooner resign than take part in such dishonest business deals.
她宁可辞职也不愿参与q种不正当的买卖.





]]>Struts 2 Tag用法 http://www.aygfsteel.com/gjhuai/archive/2007/12/30/171745.html水仁?/dc:creator>水仁?/author>Sun, 30 Dec 2007 11:43:00 GMThttp://www.aygfsteel.com/gjhuai/archive/2007/12/30/171745.htmlhttp://www.aygfsteel.com/gjhuai/comments/171745.htmlhttp://www.aygfsteel.com/gjhuai/archive/2007/12/30/171745.html#Feedback0http://www.aygfsteel.com/gjhuai/comments/commentRss/171745.htmlhttp://www.aygfsteel.com/gjhuai/services/trackbacks/171745.html 

append ?iterator

参考:http://www.roseindia.net/struts/struts2/struts2controltags/append-tag.shtml

 

在ActioncȝexecuteҎ中,实例化List对象 

public String execute()throws Exception{
    myList = new ArrayList();
    myList.add("     myList.add("Deepak Kumar");
    myList.add("Sushil Kumar");
    myList.add("Vinod Kumar");
    myList.add("Amit Kumar");

 

    myList1 = new ArrayList();
    myList1.add("
    myList1.add("Himanshu Raj");
    myList1.add("Mr. khan");
    myList1.add("John");
    myList1.add("Ravi Ranjan");
    return SUCCESS;
  }

 

jsp面中用append和iterator两个tag

 

<s:append id="myAppendList">
      <s:param value="%{myList}" />
      <s:param value="%{myList1}" />
</s:append>

   

<s:iterator value="%{#myAppendList}">
      <s:property /><br>
</s:iterator>


 

generator ?iterator

参考:http://www.roseindia.net/struts/struts2/struts2controltags/generator-tag.shtml


 

在jsp中用,'www.Roseindia.net,Deepak Kumar,Sushil Kumar,Vinod Kumar,Amit Kumar'q些内容被分行的昄在页面上?/p>

<s:generator val="%{'www.Roseindia.net,Deepak Kumar,Sushil Kumar,Vinod Kumar,Amit Kumar'}" separator=",">
    <s:iterator>
      <s:property /><br/>
    </s:iterator>
</s:generator>

   
参考:http://www.roseindia.net/struts/struts2/struts2controltags/GeneratorTagCountAttribute.shtml

count="5" -->在jsp面中显C前5?br />

<s:generator val="%{'www.Roseindia.net,Deepak Kumar,Sushil Kumar,Vinod Kumar,Amit Kumar, Sanjay, Vijay '}" count="5" separator=",">
   <s:iterator>
      <s:property /><br/>
   </s:iterator>
</s:generator>

参考:http://www.roseindia.net/struts/struts2/struts2controltags/GeneratorTagIdAttribute.shtml
<s:generator val="%{'www.Roseindia.net,Deepak Kumar,Sushil Kumar,Vinod Kumar,Amit Kumar'}" count="4" separator="," id="myAtt" />
<%
Iterator i = (Iterator) pageContext.getAttribute("myAtt");
while(i.hasNext()) {
  String s = (String) i.next(); %>
  <%=s%> <br/>
<% }
%>


 


iterator

参考:http://www.roseindia.net/struts/struts2/struts2controltags/iterator-tag.shtml

在ActioncȝexecuteҎ中实例化一个List

public String execute()throws Exception{
    myList = new ArrayList();
    myList.add("Fruits");
    myList.add("Apple");
    myList.add("Mango");
    myList.add("Orange");
    myList.add("Pine Apple");
    return SUCCESS;
  }


 

在Jsp中可以通过list的名字来调用

<s:iterator value="myList">
    <s:property /><br>
</s:iterator>


 


merge

参考:http://www.roseindia.net/struts/struts2/struts2controltags/merge-tag.shtml
在ActioncȝexecuteҎ中实例化两个List
public String execute() throws Exception{
    myList = new ArrayList();
    myList.add("www.Roseindia.net");
    myList.add("Deepak Kumar");
    myList.add("Sushil Kumar");
    myList.add("Vinod Kumar");
    myList.add("Amit Kumar");

    myList1 = new ArrayList();
    myList1.add("www.javajazzup.com");
    myList1.add("Himanshu Raj");
    myList1.add("Mr. khan");
    myList1.add("John");
    myList1.add("Ravi Ranjan");
    return SUCCESS;
  }


 

在jsp中,用merge tag把两个List合ƈQ在iterator中用merge的id来调?br />
<s:merge id="mergeId">
        <s:param value="%{myList}" />
        <s:param value="%{myList1}" />

</s:merge>
<s:iterator value="%{#mergeId}">
    <s:property /><br>
</s:iterator>
昄序Q?br /> Display first element of the first list.
Display first element of the second list.
Display second element of the first list.
Display second element of the second list.
Display third element of the first list.
Display thrid element of the second list.....and so on.


subset

参考:http://www.roseindia.net/struts/struts2/struts2controltags/subsetTag.shtml

public String execute() throws Exception{
    myList = new ArrayList();
    myList.add(new Integer(50));
    myList.add(new Integer(20));
    myList.add(new Integer(100));
    myList.add(new Integer(85));
    myList.add(new Integer(500));
    return SUCCESS;
  }


 

调用ActioncM的List

 <s:subset source="myList">
    <s:iterator>
      <s:property /><br>
    </s:iterator>
</s:subset>
在页面上昄前三?br /> <s:subset source="myList" count="3">
    <s:iterator>
      <s:property /><br>
    </s:iterator>
</s:subset>
在页面上昄?开始的3?br /> <s:subset source="myList" count="3" start="2">
    <s:iterator>
      <s:property /><br>
    </s:iterator>
</s:subset>

action tag

参考:http://www.roseindia.net/struts/struts2/struts2controltags/action-tag.shtml

The action tag is a generic tag that is used to call actions directly from a JSP page by specifying the action name and an optional namespace. The body content of the tag is used to render the results from the Action. Any result processor defined for this action in struts.xml will be ignored, unless the executeResult parameter is specified.

在struts.xml中定义action映射
<action name="actionTag" class="net.roseindia.actionTag">
       <result name="success">/pages/genericTags/success.jsp</result>
</action>

public String execute() throws Exception{
    return SUCCESS;
  }


 

在jsp面写入下面代码Q那么当hactionTag.actionӞ无论Actioncnet.roseindia.actionTag中怎么处理、如何设定页面{向,此请求直接{到successs.jsp面

<s:action name="success">
    <b><i>The action tag will execute the result and include it in this page.</i></b></div>
</s:action>


 

bean tag


参考:http://www.roseindia.net/struts/struts2/struts2controltags/bean-tag.shtml
定义一个包含name属性的普通JavaBeanQ?br /> public class companyName {
 
  private String name;

  public void setName(String name){
    this.name =name ;
  }

  public String getName(){
    return name;
  }
}


 

在jsp中调?br />
<s:bean name="net.roseindia.companyName" id="uid">
    <s:param name="name">RoseIndia</s:param>
    <s:property value="%{name}" /><br>
</s:bean>


date tag

参考:http://www.roseindia.net/struts/struts2/struts2controltags/date-tag.shtml

  private Date currentDate;
  public String execute() throws Exception{
    setCurrentDate(new Date());
    return SUCCESS;
  }

<s:date name="currentDate" format="MM/dd/yy" />

<s:date name="currentDate" format="MM/dd/yy hh:mm" />

<s:date name="currentDate" format="MM/dd/yy hh:mm:ss" />

Nice Date (Current Date & Time)Q?lt;s:date name="currentDate" nice="false" />

Nice DateQ?lt;s:date name="currentDate" nice="true" />


 


include tage

是不是可以替换frame

<body>
    <h1><span style="background-color: #FFFFcc">Include Tag (Data Tags) Example!</span></h1>
      <s:include value="myBirthday.jsp" />
  </body>


param tag

参考:http://www.roseindia.net/struts/struts2/struts2controltags/param-tag.shtml

<ui:component>
        <ui:param name="empname">Vinod</ui:param><br>
        <ui:param name="empname">Amit</ui:param><br>
        <ui:param name="empname">Sushil</ui:param>
</ui:component>


Case 1. <param name="empname">Amit</param>  Here the value would be evaluated to the stack as a java.lang.String object.
Case 2. <param name="empname" value="Vinod"/> Here the value would be evaluated to the stack as a java.lang.Object object.


set tag

参考:http://www.roseindia.net/struts/struts2/struts2controltags/set-tag.shtml


 

set tagl指定范围内的变量赋|得到name-value值对
赋|<s:set name="technologyName" value="%{'Java'}"/>
调用QTechnology Name: <s:property value="#technologyName"/>

set tag is used to assign a value to a variable in a specified scope. The parameters name and value in the tag <s:set name="technologyName" value="%{'Java'}"/> acts as the name-value pair. Here we set the parameters as name="technologyName" value="Java".

Text Tag

参考:http://www.roseindia.net/struts/struts2/struts2controltags/text-tag.shtml


 

?struts.xml 文g中定?/p>

<action name="textTag" class="net.roseindia.textTag">
       <result>/pages/genericTags/textTag.jsp</result>
</action>


在textTag.java文g所在包下,创徏一?span style="font-weight: bold">package.propertiesQ内容如下:

webname1 = http://www.RoseIndia.net
webname2 = http://www.javajazzup.com
webname3 = http://www.newstrackindia.com


 

在jsp文g调用Q如下,前三行显Cpackage.properties对应信息Q第四行昄Vinod, Amit, Sushil, .......Q最后一行empname

<s:text name="webname1"></s:text><br>
<s:text name="webname2"></s:text><br>
<s:text name="webname3"></s:text><br>
<s:text name="empname">Vinod, Amit, Sushil, .......</s:text><br>
<s:text name="empname"></s:text>

property tag

参考:http://www.roseindia.net/struts/struts2/struts2controltags/property-tag.shtml


 

定义个JavaBean

public class companyName {
 
  private String name;

  public void setName(String name){
    this.name =name ;
  }

  public String getName(){
    return name;
  }
}


 

W二行给companyName的name属性赋|W三行显C|RoseIndiaQ,相当于调用了getName()ҎQ,

<s:bean name="net.roseindia.companyName" id="uid">
<s:param name="name">RoseIndia</s:param>
  <s:property value="%{name}" /><br>
</s:bean>
<!-- Default value -->
<s:property value="name" default="Default Value" />


<s:property value="%{name}" /> it prints the result of myBean's getMyBeanProperty() method.
<s:property value="name" default="Default Value" /> it prints the result of companyName's
getName() method and if it is null, print 'a default value' instead
.

 

 



]]>
Struts 2 中Session的用?/title><link>http://www.aygfsteel.com/gjhuai/archive/2007/12/30/171735.html</link><dc:creator>水仁?/dc:creator><author>水仁?/author><pubDate>Sun, 30 Dec 2007 10:02:00 GMT</pubDate><guid>http://www.aygfsteel.com/gjhuai/archive/2007/12/30/171735.html</guid><wfw:comment>http://www.aygfsteel.com/gjhuai/comments/171735.html</wfw:comment><comments>http://www.aygfsteel.com/gjhuai/archive/2007/12/30/171735.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.aygfsteel.com/gjhuai/comments/commentRss/171735.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/gjhuai/services/trackbacks/171735.html</trackback:ping><description><![CDATA[<p>在ActionSupport子类的executeҎ中存储session<br /> Map session = <font color="#cc0000">ActionContext.getContext()</font>.getSession();<br /> <font color="#cc0000">session.put</font>("logged-in","true");</p> <p> </p> <p>同样在executeҎ中,可以清除session变量<br /> Map session = ActionContext.getContext().getSession();<br /> <font color="#cc0000">session.remove</font>("logged-in");</p> <p> </p> <p>在jsp的head部分引入css文g<br /> <head><br goog_docs_charindex="340" />      <link <font color="#cc0000" goog_docs_charindex="352">href="<s:url value="/css/main.css"/>"</font> rel="stylesheet" type="text/css"/>  <br goog_docs_charindex="428" /> </head><br /> <br /> 在jsp讉Ksession<br /> session Time: </b><%=new Date(<font color="#cc0000" goog_docs_charindex="483">session.getLastAccessedTime</font>())%> </p> <p goog_docs_charindex="518"><a href="<%= request.getContextPath() %>/roseindia/logout.action">Logout</a></p> <p goog_docs_charindex="596"> jsp中用struts-tag讉Ksession变量<br /> <s:if test<font color="#cc0000" goog_docs_charindex="636">="#session.login != 'admin'</font>"><br goog_docs_charindex="667" />  <jsp:forward page="/pages/uiTags/Login.jsp" />  <br goog_docs_charindex="718" /> </s:if><s:if color="#cc0000" test<FONT><br /> <jsp:forward page="/pages/uiTags/Login.jsp"></jsp:forward><br /> </s:if></p> <img src ="http://www.aygfsteel.com/gjhuai/aggbug/171735.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/gjhuai/" target="_blank">水仁?/a> 2007-12-30 18:02 <a href="http://www.aygfsteel.com/gjhuai/archive/2007/12/30/171735.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java对象数组的强制{换问?/title><link>http://www.aygfsteel.com/gjhuai/archive/2007/12/28/171126.html</link><dc:creator>水仁?/dc:creator><author>水仁?/author><pubDate>Fri, 28 Dec 2007 03:52:00 GMT</pubDate><guid>http://www.aygfsteel.com/gjhuai/archive/2007/12/28/171126.html</guid><wfw:comment>http://www.aygfsteel.com/gjhuai/comments/171126.html</wfw:comment><comments>http://www.aygfsteel.com/gjhuai/archive/2007/12/28/171126.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/gjhuai/comments/commentRss/171126.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/gjhuai/services/trackbacks/171126.html</trackback:ping><description><![CDATA[ Java子类对象可以强制转换为父cd象,但是子类对象数字不能强制转换为父cd象数l?br>如下Q?br><br>public void test(Number n){...}<br><br>test(new Float(2)); // q是正确?br><br>public void test2(Number n[]){...}<br><br>Float t[] = {new Float(5),<br> new Float(2),};<br><br>test2(t); //q是~译不通过的,会出C可{换的cd错误<br><br> <img src ="http://www.aygfsteel.com/gjhuai/aggbug/171126.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/gjhuai/" target="_blank">水仁?/a> 2007-12-28 11:52 <a href="http://www.aygfsteel.com/gjhuai/archive/2007/12/28/171126.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>TestLoginWebhttp://www.aygfsteel.com/gjhuai/archive/2007/12/28/171122.html水仁?/dc:creator>水仁?/author>Fri, 28 Dec 2007 03:25:00 GMThttp://www.aygfsteel.com/gjhuai/archive/2007/12/28/171122.htmlhttp://www.aygfsteel.com/gjhuai/comments/171122.htmlhttp://www.aygfsteel.com/gjhuai/archive/2007/12/28/171122.html#Feedback0http://www.aygfsteel.com/gjhuai/comments/commentRss/171122.htmlhttp://www.aygfsteel.com/gjhuai/services/trackbacks/171122.html01 /**
02 * 本程序可以模拟webd。向服务器端提交数据?/FONT>
03 * 1、向服务器post多个参数Ӟ如何做?
04 * 2、如何取得一个连接的Cookie和sessionId?
05 * 3、如何用sessionId讉K一个网站?
06 */
07
08 import java.io.BufferedReader;
09 import java.io.IOException;
10 import java.io.InputStreamReader;
11 import java.io.OutputStream;
12 import java.net.HttpURLConnection;
13 import java.net.URL;
14
15
16 public class TestLoginWeb {
17
18 public static void main(String args[]) throws IOException {
19
20 URL url = new URL("http://localhost:8080/backgroundH/login.jsp");
21 URL url1 = new URL("http://localhost:8080/backgroundH/execute.jsp");
22 HttpURLConnection huc = (HttpURLConnection) url.openConnection();
23
24 // 讄允许output
25 huc.setDoOutput(true);
26 // 讄为post方式
27 huc.setRequestMethod("POST");
28 huc.setRequestProperty("user-agent", "mozilla/4.7 [en] (win98; i)");
29
30 OutputStream os = huc.getOutputStream();
31 // 多个参数的输出时Q需要用&q接Qƈ转换成bytes
32 os.write("name=gaolei".getBytes("gbk"));
33 os.close();
34
35 BufferedReader br = new BufferedReader(
36 new InputStreamReader(huc.getInputStream()));
37
38 huc.connect();
39 String line = br.readLine();
40
41 while (line != null) {
42 System.out.println(line);
43 line = br.readLine();
44 }
45
46 // 取得cookie
47 String cookieval = huc.getHeaderField("set-cookie");
48
49 System.out.println(cookieval);
50 String sessionid = null;
51
52 // 取得cookieQ这D代码对于不同网站不同,因ؓ有的|站有多个session标识
53 if (cookieval != null) {
54 sessionid = cookieval.substring(0, cookieval.indexOf(";"));
55 }
56
57 huc.disconnect();
58 huc = null;
59
60 HttpURLConnection huc1 = (HttpURLConnection) url1.openConnection();
61 // 使用sessionId讉K一个网?/FONT>
62 huc1.setRequestProperty("cookie", sessionid);
63 // 讄允许output
64 huc1.setDoOutput(true);
65 // 讄为post方式
66 huc1.setRequestMethod("POST");
67 huc1.setRequestProperty("user-agent", "mozilla/4.7 [en] (win98; i)");
68
69 OutputStream os1 = huc1.getOutputStream();
70
71 os1.write("value=1234567890".getBytes("gbk"));
72 os1.close();
73
74 BufferedReader br1 = new BufferedReader(
75 new InputStreamReader(huc1.getInputStream()));
76
77 huc1.connect();
78 line = br1.readLine();
79 while (line != null) {
80 System.out.println(line);
81 line = br1.readLine();
82 }
83 huc1.disconnect();
84
85 }
86 }
87

W?1行,关于POST多个参数到服务器端,可以参照下面代码Q?/P>

StringBuffer params = new StringBuffer("typeid=");
params.append(args[0]).append("&");
params.append("keyword=").append(args[1]);

os.write(params.toString().getBytes("gb2312"));



]]>
վ֩ģ壺 | | | ¡| ˮ| ɽ| | Ͱ| ɫ| | ԭ| ߺ| ³| Ž| | | | ͭ| ɽ| ӽ| | ³ľ| Ϋ| | | | | | | | | | ij| | | ҽ| ɽ| | | ÷| ֶ|