$(window).load(function(){
$("#content_1").mCustomScrollbar({
scrollButtons:{
enable:true
}
});
// ajax code
function beauty_of_ceylon() {
$('.content-text').html('<p style="position:absolute;"><img src="images/ajax-loader.gif" /></p>');
$('.content-text').load("packages/beauty-of-ceylon.php");
}
Run Code Online (Sandbox Code Playgroud) 如何在Spring MVC 3的控制器中将多个对象添加到ModelAndView中?那可能吗?
我有一个类似于以下内容的枚举类:
public enum MyEnum {
VALUE1("value.1"),
VALUE2("value.2");
private String value;
private MyEnum(String value) { this.value = value; }
public String getId() { return id; }
}
Run Code Online (Sandbox Code Playgroud)
我想对枚举的值有一个switch语句.类似于以下内容:
switch (myString) {
case MyEnum.VALUE1.getId():
...
}
Run Code Online (Sandbox Code Playgroud)
我得到以下编译时错误:case表达式必须是常量表达式.
有没有办法让它与enum和switch语句一起使用?我在枚举中添加值的原因是因为我想要一些带有"."的ID.和其他不允许的字符.
我最近在Spring Framework中下载了Spring MVC(Version 4.0.2.RELEASE)模块的源代码.我的目的是针对模块的实际源代码而不是实际.jar文件运行.(长话,仅用于测试目的).
下载源代码后,我jar从项目中删除了文件,编译并部署到服务器.当我点击调度程序servlet处理的其中一个URL时,我遇到了错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0': Invocation of init method failed; nested exception is java.lang.Error: Unresolved compilation problems:
The import java.time cannot be resolved
The method toZoneId() is undefined for the type TimeZone
ZoneId cannot be resolved
Run Code Online (Sandbox Code Playgroud)
经过一些研究和挖掘源代码后,我意识到错误中提到的类是JDK/JRE 1.8的一部分.在删除.jar文件之前,我的项目在JDK/JRE 1.7上运行没有问题.
我的问题是Spring如何包含JDK 1.8中的类,但仍设法在JDK/JRE 1.7下运行?为什么在使用Spring的.jar文件时不会抛出异常,但是当我提供源代码时它被抛出(并且缺少jar文件)?
全栈跟踪
Mar 26, 2014 7:27:18 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet dispatcher
java.lang.Error: Unresolved compilation problems:
The import java.time cannot be …Run Code Online (Sandbox Code Playgroud) 我有这样的事情:
<div id="page">
<---some content here -->
<div id="container">
<div id="child">
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
现在,#page它没有任何格式.它的工作正常some content,我的意思是,当内容越大时,它#page也越高.但是,今天我应用#container它,它定位absolute,并在其中有一个#child定位relative,似乎#container不在#page- 这意味着如果#container增长,高度#page不变,为什么?
我正在尝试以下Java代码段:
int[] testArray={10,20,30,40};
int i= 0;
testArray[i++]= testArray[i++]+1;
System.out.println("The value of i: "+i);
for(int i1=0;i1<testArray.length;i1++)
{
System.out.println(testArray[i1]);
}
Run Code Online (Sandbox Code Playgroud)
当i = 0时,数组的输出值为: 21, 20,30,40
我无法理解这个输出,因为输出应该是: 10, 11, 30, 40
testArray[0]+1会是11,它会被分配给testArray[1]但不是这样的.任何人都可以解释输出吗?
所以我有以下HTML。这个想法是,默认情况下,用户可以输入2个团队,但是他们应该可以选择添加更多团队。我的添加新团队功能可以完美运行-
我正在尝试做的是允许用户删除他们添加的输入。这样他们就可以
我有点挣扎着如何添加一个“删除”按钮和jQuery。
这是一个jsFiddle http://jsfiddle.net/sqn9Y/
所有帮助非常感谢!
<div class="control-group">
<div id="teamArea"class="controls">
<input type="text" name="teamName[]">
<input type="text" name="teamName[]">
</div>
<a id="addNewTeam">Add another</a>
</div>
$("#addNewTeam").click(function(e) {
//Append new field
e.preventDefault();
var newField = $('#teamArea input:first').clone();
newField.val("");
$("#teamArea").append(newField);
});
Run Code Online (Sandbox Code Playgroud) 看下面的代码
import java.util.Enumeration;
import java.util.Vector;
public class Modification_On_Eumeration {
public static void main(String[] args) {
Vector<Integer> vector = new Vector<Integer>();
vector.add(1);
vector.add(2);
System.out.println(vector);
Enumeration<Integer> enumeration = vector.elements();
while (enumeration.hasMoreElements()) {
Integer integer = (Integer) enumeration.nextElement();
System.out.print(integer);
}
System.out.println();
System.out.println("first loop finished");
vector.add(3);
while (enumeration.hasMoreElements()) {
Integer integer1 = (Integer) enumeration.nextElement();
System.out.println(integer1);
}
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码工作正常,输出是:
[1, 2]
12
first loop finished
3
Run Code Online (Sandbox Code Playgroud)
现在看下面的代码:
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;
public class Fail_Safe_Iterator {
public static void main(String[] args) {
CopyOnWriteArrayList<Integer> copyOnWriteArrayList=new CopyOnWriteArrayList<Integer>(); …Run Code Online (Sandbox Code Playgroud) 我在下面有一个示例类,我想返回某些类型的所有类字段,在此类型为Image的示例中.
public class Contact {
private String surname, lastname, address;
private int age, floor;
private Image contactPhoto, companyPhoto;
private boolean isEmployed;
public String[] getAllImages() {
String images[] = // missing code
return images;
// in this case, I want to return {"contactPhoto","companyPhoto"}
}
}
Run Code Online (Sandbox Code Playgroud)
我需要一个帮助.如何查找特定类型的所有类字段.我将在另一个类c中调用此方法.
在我的标记中,我的A元素的href等于"": <a href="">.例如alert(jQuery('#my_href_link').attr('href')),当尝试使用类似的方式显示它时,它返回"未定义"而不是空链或其他东西.
所以我到处找到的解决方案:
if (jQuery('#my_href_link').attr('href') == '')
Run Code Online (Sandbox Code Playgroud)
要么
if (jQuery('#my_href_link').attr('href').length == 0)
Run Code Online (Sandbox Code Playgroud)
......不行.
然而它们似乎适用于除我之外的所有人.这是为什么?
标记:
<a id="my_href_link" href="">
<img src="image.jpg">
</a>
Run Code Online (Sandbox Code Playgroud) 以下是我的javscript的一部分(使用jquery).
list = ['a', 'b', 'c'];
for(var i = 0 ; i< list.length ; i++) {
$("<a>click here</a>").
click(function(){
foo(list[i]);
}).
appendTo('#sometag');
}
function foo(val) {
console.log(val);
}
Run Code Online (Sandbox Code Playgroud)
无论您点击哪个标签,都会打印c.如何打印正确值???
它似乎正在使用i = 3的最后一个值,因此总是评估oc
java ×5
jquery ×4
html ×2
javascript ×2
spring ×2
ajax ×1
arrays ×1
closures ×1
collections ×1
controller ×1
css ×1
enumeration ×1
enums ×1
iterator ×1
java-8 ×1
model ×1
reflection ×1
spring-mvc ×1
validation ×1