buffalo2.0 + SSH

buffalo2.0 + SSH
需要 buffalo2.0.jar 和 prototype.js buffalo.js
1. web.xml 中加入:
<!--初始化WebApplicationContext-->
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
<listener>
  <listener-class>
	org.springframework.web.context.ContextLoaderListener
  </listener-class>
</listener>
<!-- end -->
<!-- 配置buffalo.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>
<!-- end -->

2. buffalo.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
	<bean id="ajaxTree" class="com.tree.ajax.ajaxTreeService">   
		<property name="treeService" ref="treeService"/>
	</bean>
	<bean name="buffaloConfigBean" class="net.buffalo.service.BuffaloServiceConfigurer">
		<property name="services">
			<map>
				<entry key="springAjaxTree">
					<ref bean="ajaxTree"/>
				</entry>
			</map>
		</property>
	</bean>	
</beans>


3. JSP 注意 js 的导入顺序!不然可能提示脚本错误: 'Class' 未定义
<script language="JavaScript" src="scripts/prototype.js"/>
<script language="JavaScript" src="scripts/buffalo.js"/>
<script language="javascript" type="text/javascript">
	var endPoint="<%=request.getContextPath()%>/bfapp";
	var buffalo = new Buffalo(endPoint);
</script>

你可能感兴趣的:(java,spring,xml,Web,ssh)