- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试不同的方法来制作 4 个依赖的下拉菜单。通过选择第一个填充 2,选择第二个填充第三个下拉列表,选择第三个下拉列表,获取第四个下拉列表的项目列表。
在进行研究时,我发现这与我的想法很接近。这样就可以正常使用jsp和ajax了。我正在寻找一个基于 struts2 的,并且这个示例使用多个页面来获取列表。每个列表都基于不同的 jsp 页面。 http://www.roseindia.net/answers/viewqa/Ajax/15250-DropDown-in-ajax+jsp.html
strtus2 双重选择工作得很好,但它仅限于两个下拉菜单。无论如何,我们是否可以将其扩展到更多或任何教程或帮助,非常感谢。
最佳答案
Struts2-Jquery 有助于使该解决方案发挥作用。但谷歌并没有提供太多帮助,教程只完成了一半。我认为这对于其他想要在项目中实现的人来说将会很有用。因此下面分享一下。我将尝试上传此 war 文件并在此处共享链接。
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:javaee="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_9" version="2.4">
<display-name>Struts2 Application</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
<package name="default" extends="json-default" namespace="/">
<action name="jsonsample" class="net.action.JsonSample">
<result type="json" />
</action>
</package>
</struts>
index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<sj:head jqueryui="true" />
<div id="col3">
<div id="col3_content" class="clearfix">
<s:form id="formSelectReload" action="jsonsample" theme="simple"
cssClass="yform">
<fieldset>
<legend>AJAX Form</legend>
<div class="type-text">
<label for="language">Country: </label>
<s:url id="remoteurl" action="jsonsample" namespace="/"/>
<sj:select href="%{remoteurl}" id="country" onChangeTopics="reloadsecondlist" name="country"
list="countryMap" listKey="myKey" listValue="myValue" emptyOption="false"
headerKey="-1" headerValue="Please Select a Country"/>
</div>
<div class="type-text">
<label for="echo">State: </label>
<s:url id="remoteurl" action="jsonsample" namespace="/"/>
<sj:select href="%{remoteurl}" id="stateID" onChangeTopics="reloadThirdlist" formIds="formSelectReload"
reloadTopics="reloadsecondlist" name="state"
list="stateMap" listKey="myKey" listValue="myValue" emptyOption="false"
headerKey="-1" headerValue="Please Select a State"/>
</div>
<div class="type-text">
<label for="echo">City: </label>
<s:url id="remoteurl" action="jsonsample" namespace="/"/>
<sj:select href="%{remoteurl}" id="cityId" formIds="formSelectReload" reloadTopics="reloadThirdlist"
name="echo" list="cityList" emptyOption="false"
headerKey="-1" headerValue="Please Select a City"/>
</div>
</fieldset>
</s:form>
</div>
</div>
JSonSample.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.opensymphony.xwork2.ActionSupport;
public class JsonSample extends ActionSupport {
private Map<String,String> countryMap;
private Map<String,String> stateMap;
private List<String> cityList;
private String country;
private String state;
private String city;
public String execute() {
countryMap = new HashMap<String,String>();
countryMap.put("1", "USA");
countryMap.put("2", "India");
stateMap = new HashMap<String,String>();
if(country != null && country.equalsIgnoreCase("1")){
stateMap.put("1", "New York");
stateMap.put("2", "new jersey");
} else if(country != null && country.equalsIgnoreCase("2")){
stateMap.put("1", "Karnataka");
stateMap.put("2", "Andhra Pradesh");
}
cityList = new ArrayList<String>();
if(country != null && country.equalsIgnoreCase("1") && state != null && state.equalsIgnoreCase("1")){
cityList.add("New York City 1");
cityList.add("New York City 2");
} else if(country != null && country.equalsIgnoreCase("1") && state != null && state.equalsIgnoreCase("2")){
cityList.add("New Jersey City 1");
cityList.add("New Jersey City 2");
} else if(country != null && country.equalsIgnoreCase("2") && state != null && state.equalsIgnoreCase("1")){
cityList.add("Karnataka City 1");
cityList.add("Karnataka City 2");
} else if(country != null && country.equalsIgnoreCase("2") && state != null && state.equalsIgnoreCase("2")){
cityList.add("AP City 1");
cityList.add("Ap City 2");
}
return SUCCESS;
}
public String getJSON() {
return execute();
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public Map<String, String> getCountryMap() {
return countryMap;
}
public Map<String, String> getStateMap() {
return stateMap;
}
public List<String> getCityList() {
return cityList;
}
public String index() {
return "success";
}
}
使用的 Jar 文件:
commons-fileupload-1.3.1.jar
commons-io-2.2.jar
commons-lang-2.4.jar
commons-lang3-3.1.jar
commons-logging-1.1.3.jar
commons-logging-api-1.1.jar
freemarker-2.3.19.jar
javassist-3.11.0.GA.jar
ognl-3.0.6.jar
struts2-core-2.3.16.3.jar
struts2-jquery-plugin-3.7.0.jar
struts2-json-plugin-2.3.16.3.jar
xwork-core-2.3.16.3.jar
关于drop-down-menu - 使用struts2 3个或更多依赖下拉菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23746323/
我正在使用 gfx-hal,这需要我创建需要使用特定于其类型的函数显式销毁的资源。我想将这些类型的实例存储在结构中,并且我还想将清理它们与拥有结构的生命周期相关联,而不是手动管理它们的生命周期并可能在
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 7 年前。 Improve
我知道这一定是非常明显的事情,但我不明白。我有两个 div,一个可拖动,另一个带有 on:drop,当我将可拖动的 div 放到它上面时,它似乎没有被调用。我错过了什么? 回复:https://sve
在下面的应用程序中,从未调用 drop 方法。放置目标 ( div2 ) 由 dragEnter 和 dragOver 事件中的取消事件指示,但不触发放置。 HTML 和 .dart 如下:
我已经使用 ng2 文件上传实现了文件删除。我面临的问题是,当文件被拖放到拖放区域之外时,浏览器会打开它。有什么办法可以防止这种事件发生吗? Angular 2/4 最佳答案 是的,终于成功了。我希望
我是使用rust 的新手。我的简单代码 struct Foo{ data : & 'a String, } fn test_foo(){ let s1:String = String::
我希望 image.src 显示 id,而不是每个 的值。 drop.id 存在吗?这可以做到吗?或者id被锁定在中?当用户点击提交时,我需要传递表单中的值。 function swapImage
我正在使用一个数据框,我必须将两列(定量和销售)添加然后删除它们,然后将列名称的第一个字母大写。问题是当我使用 drop 时,它会将其保存到另一个数据帧。从文档来看,问题来自 inplace=fals
我想让 Drop left 而不是在 bootstrap 下拉按钮中下拉。我正在努力实现这一点,但我无法做到这一点,有人可以指导我这样做吗? 这是我的代码 Small button
我在使用 Blazor 时遇到了一个奇怪的问题... 我有一个使用拖放功能的应用程序,它使用 .Net Core 3.1 运行良好。然而,无论我做什么,drop 事件现在都不会被解雇,我不知道为什么。
我希望能够移动(在灰色背景上,通过拖放)Bootstrap 2 提供的模态表单。谁能告诉我实现此目的的最佳实践是什么? 最佳答案 默认情况下, Bootstrap 不附带任何拖放功能,但您可以添加一些
我试图在拖放过程中更改节点上的光标,但图像没有改变。我打电话 setCursor()在 DragDetectedEventHandler我的节点。我也试过调用 getParent().setCurso
我刚刚注意到您可以在 PostgreSQL 中编写两者。有什么区别还是只是“简化”的语法。据我所知,这两者的作用完全相同。 ALTER TABLE table DROP my_column; 对比 A
我将屏幕分为两个 DIV。在左侧的 DIV 中,我有一些 50x50 像素的 DIV,在右侧的 DIV 中,我有一个由 80x80 LI 组成的空网格 。左侧的 DIV 是可拖动的,一旦放到 LI 上
我正在使用这个库 Drop ,但是记录很差,我不明白如何使用它。首先我安装了: npm install tether-drop 我已经下载了 Drop.js,然后用 Tether 导入它(导入所有内容
我想使用 jQuery 处理拖放 HTML 5 功能。直到没有触发 drop 事件为止都可以。看看我的代码: A B C $('#columns .column').on({
我需要使用 mysqldump 和 replace 而不是 insert 并且在恢复时不删除数据库和表。但我需要删除并重新创建触发器和存储过程 为此,我将 mysqldump 与 --replace
在 CD 管道中,我使用下载构建工件任务将工件下载到目标目录。我的发布工件目录结构如下 drop --> 来源 --> abc.zip 现在的问题是,每当我下载工件时,它都会下载整个放置文件夹并将相同
您好,我正在开发拖放应用程序。我有一个可以沿着文档拖动的 DIV,并且文档中还有其他一些 div,我可以将一个 div 拖到其他 div,这会使页面变得困惑它在空的地方并禁用另一个 div 中的放置,
我有以下代码: $(".dropzone").on("dragover", function(ev) { ev.preventDefault();
我是一名优秀的程序员,十分优秀!