说明:这个工程的环境需要:JSP自定义标签、dwr,这个例子提供了几个实际应用的例子,包括了修改时候自动选中等。
首先看看web.xml的配置:
1、
<?xml version="1.0" encoding="UTF-8"?>
<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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>dwr-remote</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-remote</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<jsp-config>
<taglib>
<taglib-uri>/tag</taglib-uri>
<taglib-location>/WEB-INF/ne.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>
2、dwr的配置文件dwr.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 3.0//EN" "dwr30.dtd">
<dwr>
<allow>
<create creator="new" javascript="LINK">
<param name="class" value="com.core.LinkageAdapter"></param>
</create>
</allow>
</dwr>
3、tag.xml,jsp自定义标签的配置文件
<?xml version="1.0" encoding="utf-8"?>
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<uri>/tag</uri>
<tag>
<name>select</name>
<body-content>empty</body-content>
<info>下拉框标签</info>
<tag-class>com.tag.link.SelectTag</tag-class>
<attribute>
<description>select框的name属性</description>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<name>name</name>
</attribute>
<attribute>
<description>select框的sql属性</description>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<name>sql</name>
</attribute>
<attribute>
<name>bind</name>
<description>绑定下一级别的ID属性</description>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>bindSelectValue</name>
<description>绑定联动的下拉框的值,当联动的下拉框的值为当前的值的时候选中</description>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>bindSql</name>
<description>下一级别的查询SQL语句</description>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>select:link</name>
<body-content>empty</body-content>
<info>联动的子级标签</info>
<tag-class>com.tag.link.LinkSelect</tag-class>
<attribute>
<description>select框的name属性</description>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<name>name</name>
</attribute>
<attribute>
<name>bind</name>
<description>绑定下一级别的ID属性</description>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>bindSql</name>
<description>绑定下一级别的ID属性</description>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>bindSelectValue</name>
<description>选中该下拉框的属性值</description>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
4、有了上面的配置后,在jsp页面调用如下:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="tag" uri="/tag" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>下拉联动的测试</title>
<style type="text/css">
*{
padding: 15px;
}
</style>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<script type='text/javascript' src='<%=request.getContextPath() %>/dwr/interface/LINK.js'></script>
<script type='text/javascript' src='<%=request.getContextPath() %>/dwr/engine.js'></script>
<script type='text/javascript' src='<%=request.getContextPath() %>/dwr/util.js'></script>
</head>
<body>
<fieldset>
<legend>省县乡级联</legend>
<tag:select name="province" sql="select povinceid,povincename from povince" bind="city"
bindSql="select cityid,cityname from city where father = " />
<tag:select:link name="city" bind="area"
bindSql="select areaid,areaname from area where father = "/>
<tag:select:link name="area" />
</fieldset>
<fieldset>
<legend>省县级联</legend>
<tag:select name="sheng" sql="select povinceid,povincename from povince" bind="xian" bindSql="select cityid,cityname from city where father = "/>
<tag:select:link name="xian" />
</fieldset>
<fieldset>
<legend>县乡级联</legend>
<tag:select name="xianxian" sql="select cityid,cityname from city " bind="xiangxiang" bindSql="select areaid,areaname from area where father = "/>
<tag:select:link name="xiangxiang" />
</fieldset>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/select.js"></script>
</body>
</html>
5、请注意查看标签调用的那部分,这个页面就实现了3组的联动,详细的就不说了,附上可以运行的工程。
详细也可以看
http://haiyangyiba.iteye.com/admin/blogs/650250
这里有详细的信息。
分享到:
相关推荐
dwr无限极下拉联动(运行6级下拉联动效果演示含说明,数据库数据来源于数据库中 这里为一个视频演示程序,有什么疑问可以留言。 这个视频是一个avi的文件,压缩后不到8M,源文件有500M,需要看看的朋友可以下载。
php后台无限极栏目菜单+数据库
无限极列表相关增删改查 PHP+HTML 实现 无 框架
通过ajax实现无限极联动,解决传统意义上的多级菜单功能,实现异步刷新
mysql(多级分销)无限极数据库设计方案(邻接表,路径枚举,闭包表,嵌套集);前三种好理解,最后一种嵌套集设计需要程序维持完整性,这里着重讲解设计思路,并附有Golang实现的源码(增删改查),各位同仁可斟酌...
带有演示数据,jquery无限极复选框下拉树,父级全选,子级单选都可以。
这是一套VUE全家桶的Demo里面有数据来源,和JS代码,4级联动下拉组件,可以随意更改,可二次开发无限极联动。
jQuery无限极多级导航下拉菜单是一款简单实用的导航菜单插件,支持多级无限极下拉菜单展开效果代码。
jquery插件的无限极下拉菜单
全网最详细的省市区数据库 ,五级联动,2021年最新整理!
省市联动,无限极分类下拉选择插件 简介 无限极分类下拉选择插件,经历数个版本,最初使用的jquery bind函数绑定select标签onchange事件。 当前版本使用jquery delegate 方式进行事件处理,代码得到了大大的精简。 ...
找了很久的c#TreeView目录树,结合数据进行无限极目录树,采用的是递归模式,压缩包里包含数据库,应该是我找到的最好的代码了
无限极分类,数据库存储过程实现无限极分类信息
本篇文章是对可扩展的无限极联动下拉选项的实例进行了分析介绍,需要的朋友参考下
此文档使用TreeView控件绑定实现了无限极分类,数据库一个表使用了三个字段
JAVAWEB MVC模式开发的jsp无限极分类程序。 此程序采用servlet + jsp + javabean 的MVC模式开发。 支持无限极分类。 可以作为一个独立模块来嵌入您的系统或网站开发中使用。 此程序以最简洁的方式实现了分类功能,...
通用无限极下拉菜单的实现代码_.docx
下面小编就为大家带来一篇通用无限极下拉菜单的实现代码。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
AJAX无限级联动菜单 使用ASP.NET+AJAX和ACCESS数据库开发 简单易懂
数据库动态切换技术,数据库连接字符串加密,自定义标签进阶--自定义标签类库的实现。动态上传并选择自定义模板功能,基于IO,伪静态,HttpHeader三种整合后的静态页生成方式,静态页分页高效率方式。Jquery动态无...