Hoyi 新特性用法(hoyi入门系列文章七)
1.hoyi的方法新特性,方法访问路径
示例代码:在项目里增加demo6包,并增加Demo6Controller类并继承Hoyipage
public class Demo6Controller extends Hoyipage {@RequestMode(MODE={RequestType.POST,RequestType.GET})
public void testMe(){
this.WriteUTF8HTML("测试新特性方法");
}
}
hoyi 的方法访问通常采用 ip:端口/类路径.后缀?behavior=方法 的方式,这种是通过反射的方式去处理。
hoyi现在支持一种效率更高的访问方式(使用缓存内存来处理) ip:端口/类路径/方法.后缀
底层在DispatcherServlet 增加了dispatchers.add(new MappingDispatcher());
在MappingDispatcher 里做了处理。
访问 http://localhost:8085/hoyidemo/demo6/Demo6Controller/testMe.html
2.hoyi的方法新特性,带参数的方式
hoyi的增加了支持带参数访问直接获取参数的方式
需要设置在Eclipse编译时保留方法的形参,如图所示:
示例代码:
@RequestMode(MODE={RequestType.POST,RequestType.GET})
public void testParam(String param1,String param2){
this.WriteUTF8HTML("测试新特性方法 的参数1为"+param1+"参数2 为"+param2);
}
访问 http://localhost:8085/hoyidemo/demo6/Demo6Controller/testParam.html?param1=param1¶m2=param2