1. 需要使用的Buffalo包:buffalo-core-2.0.jar,Sping中的核心包 spring-2.0.3.jar。
2. 在工程的web.xml引入buffalo。中配置如下:
在web.xml中配置:
<servlet>
<servlet-name>bfapp</servlet-name>
<servlet-class>
net.buffalo.web.servlet.ApplicationServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>bfapp</servlet-name>
<url-pattern>/bfapp/*</url-pattern>
</servlet-mapping>
3. 在spring的配置文件配置如下,其中<ref bean="paramService"/>
paramService表示service中的标示。
<bean name="buffaloConfigBean" class="net.buffalo.service.BuffaloServiceConfigurer">
<property name="services">
<map>
<entry key="paramService">
<ref bean="paramService"/>
</entry>
</map>
</property>
</bean>
4. 在jsp页面,首先需要引入prototype.js、buffalo.js两个js文件
var resultObj;
var END_POINT="<%=request.getContextPath()%>/bfapp";
var buffalo = new Buffalo(END_POINT,false);
buffalo.remoteCall("paramService.getInformation",[var_name], function(reply)
{
resultObj = reply.getResult();
});
if(resultObj)
{
var str = "<select name='paramValue' style='width:80px'>";
for(var i=0; i < resultObj.length; i++)
{
str += "<option value=" + resultObj[i].code + ">" + resultObj[i].name + "</option>"
}
str += "</select>"
objSpan.innerHTML = str;
}
其中paramService.getInformation中getInformation:表示上面spring中的服务类中的方法。getInformation(String name);