我需要使用特定对象的属性(Location)获取多个对象列表(Student),代码如下所示,
List<Student> studlist = new ArrayList<Student>();
studlist.add(new Student("1726", "John", "New York"));
studlist.add(new Student("4321", "Max", "California"));
studlist.add(new Student("2234", "Andrew", "Los Angeles"));
studlist.add(new Student("5223", "Michael", "New York"));
studlist.add(new Student("7765", "Sam", "California"));
studlist.add(new Student("3442", "Mark", "New York"));
Run Code Online (Sandbox Code Playgroud)
我根据位置需要3个单独的列表.
1.Newyork list 2.California list 3.Los Angeles list
谁能在这里告诉我正确的方法?提前致谢.
我在spring mvc工作,我正在做一些jsp,在一个页面中显示多个下拉列表....
我看到一个示例,通过使用以下示例显示从数据库下拉.
<%@ page import="java.util.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:useBean id="state" scope="session" class="src.StateDAO"/>
<html>
<head>
<title></title>
</head>
<body>
<form id="test" method="POST" action="">
<input name="state" type="radio" value="Australia" id="state-aus">Australia
<input name="state" type="radio" value="NewZealand" id="state-new">NewZealand
<input name="state" type="radio" value="India" id="state-oth" >India
<Select name="othStates" size="1" id="oth-states">
<c:forEach items="${state.stateList}" var="st">
<option value="1"><c:out value="${st.name}"/></option>
</c:forEach>
</select>
<br>
<input type="Submit" name="cmdSub" value="SUBMIT">
<input type="Reset" name="cmdReset" value="RESET">
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是使用Spring mvc在jsp中获取下拉菜单的正确方法吗?
我在JavaScript中获得了文本框值.我的文本框值是"xxxxx?000-1111".当我试图从JavaScript函数中获取此值时,我得到的值为[object%20HTMLDivElement] ....任何人都可以告诉我,我在这里犯了什么错误.
文本框和按钮,文本框值从其他方法替换,并在页面中显示良好.
function clDoc() {
path = document.getElementById('val').value;
alert(path);
var myWindow = window.open(path, '', 'width=520,height=650');
}
<input type="text" id="clDoc" name="myn" value="" />
<input type="button" onClick="clDoc()" value="View" id="groupbtn" />
Run Code Online (Sandbox Code Playgroud)
使用Javascript
function clDoc() {
path = document.getElementById('val');
alert(path);
var myWindow = window.open(path, '', 'width=520,height=650');
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试了以下,我会收到警告,因为未定义.
function clDoc() {
path = document.getElementById('val').value;
alert(path);
var myWindow = window.open(path, '', 'width=520,height=650');
}
Run Code Online (Sandbox Code Playgroud)