struts2实现级联菜单

jsp+struts2实现最好... jsp+struts2实现最好 展开
 我来答
匿名用户
2010-12-08
展开全部
<%@ taglib prefix=”s” uri=”/struts-tags” %>
<%@ page language=”java” errorPage=”/error.jsp” pageEncoding=”GBK” contentType=”text/html;charset=GBK” %>
<html>
<head>
<title>Struts 2 Cool Tags - <s:doubeselect/ ></title>
<s:head />
</head>
<body>
<h2>Doubleselect Tag Example</h2>
<s:form action=”doubleSelectPost” name=”form1〃>
Doubleselect演示1
<s:set name=”technology”
value=”#{
‘Java’: {’Spring’, ‘Hibernate’, ‘Struts 2′},
‘.Net’: {’Linq’, ‘ ASP.NET 2.0′},
‘Database’: {’Oracle’, ‘SQL Server’, ‘DB2′, ‘MySQL’}
}” />
<s:doubleselect label=”技术选择”
list=”#technology.keySet()”
name=”doubleselect1〃
doubleName=”techdetail”
formName=”form1〃
doubleList=”#technology[top]” />
<br/><br/>
Doubleselect演示数据演示2:
<s:set name=”mymap” value=”#request.map”/>
<s:doubleselect list=”#request.map.keySet()”
doubleName=”mymap1〃
name=”doubleselect2〃
formName=”form1〃
doubleList=”#request.map[top]”
label=”Map Test” />

<s:submit/>
</s:form>
</body>
</html>
doubleselectpost.jsp

<%@ taglib prefix=“s” uri=“/struts-tags” %>
<%@ page language=“java” errorPage=“/error.jsp” pageEncoding=“GBK” contentType=“text/html;charset=GBK” %>
<html>
<head>
<title>Struts 2 Cool Tags - <s:doubeselect/ ></title>
<s:head />
</head>
<body>
<h2>Doubleselect Tag Example</h2>
<s:form name=“form1〃>
<table border=“0〃 cellspacing=“0〃 cellpadding=“1〃>
<tr>
<th>参数值</th>
</tr>
<s:iterator value=“#request.map.keySet()” status=“keys”>
<tr>
<td><s:property/></td>
</tr>
</s:iterator>
</s:form>
</body>
</html>
3、struts.xml配置文件
<action name=”doubleSelectTest” method=”doubleSelectTest” class=”com.mobilesoft.esales.webapp.action.DoubleListAction”>
<result name=”success”>test/doubleselect.jsp</result>
</action>
<action name=”doubleSelectPost” method=”doubleSelectPost” class=”com.mobilesoft.esales.webapp.action.DoubleListAction”>
<result name=”success”>test/doubleselectpost.jsp</result>
</action>
4、级联下拉框间的换行<br >问题
缺省情况下,两个级联下拉框间是换行的,Struts2采用Freemarker来做模板,可以通过修改模板来定制标签缺省的树形。参看“Struts2中Datetimepicker控件的中文问题”中的方法,也即:

修改struts.mxl,增加如下内容。
<constant name=”struts.serve.static” value=”false” />

<constant name=”struts.ui.templateDir” value=”struts” />

注意在struts2-core-2.0.11.jar/org/apache/struts2/default.properties中有几个与Freemarker对应的配置参数:

struts.ui.theme=xhtml
struts.ui.templateDir=template
#sets the default template type. Either ftl, vm, or jsp
struts.ui.templateSuffix=ftl

覆盖缺省的静态文件
在resource目录(与WEB-INF同级或WEB-INF下)创建struts目录,并:

解压struts2-core-2.0.11.jar:/org/apache/struts2/static/ to /struts/

解压struts2-core-2.0.11.jar:/template/simple/ to /struts/simple/

解压struts2-core-2.0.11.jar:/template/xhtml/ to /struts/xhtml/

解压struts2-core-2.0.11.jar:/template/css_xhtml/ to /struts/css_xhtml/

解压struts2-core-2.0.11.jar:/template/ajax/ to /struts/ajax/

解压struts2-core-2.0.11.jar:/template/archive/ to /struts/archive

最后的目录结构如下:

struts/
- ajax/
- archive/
- css_xhtml/
- dojo/
- nls/
- src/
- animation/
- …
- xml/
- struts/
- widget/
- widgets/
- niftycorners/
- simple/
- xhtml/

修改doubleselect的模板doubleselect.ftl
修改struts/simple/doubleselect.ftl去除其中的<br />

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/feifmail/archive/2008/10/08/3031700.aspx
百度网友a668673
2010-12-07 · TA获得超过527个赞
知道小有建树答主
回答量:425
采纳率:0%
帮助的人:330万
展开全部
级联菜单非ajax的话,跟struts2和jsp是没啥关系的,纯js的东西,网上很多现成的东西
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式