我在jsp中有一个forEach循环,循环遍历一个对象列表并显示每个对象的html表数据.我想在每个表下面有一个导出链接用于不同的数据格式,我能够将对象列表传递给导出控制器.
我的问题是:由于每次通过jsp循环我都会去控制器,我不知道如何保留索引,所以我只能导出当前对象.我
1.)在jsp循环中放置一个计数器并将其传递给控制器以确定当前列表索引?
2.)在我的实现类中有一些计数器,每次从jsp出来时它都会增加并保留它的值吗?
或者,还有更好的方法?
我试图完成一个绘制图形并将其写入PDF的示例,但我不断收到PDF没有页面的错误.如果我在打开后用document.add()添加一些简单的东西就可以正常工作,我只是看不到图形.这是我的代码:
Document document = new Document();
PdfWriter writer = new PdfWriter();
response.setContentType("application/pdf");
response.setHeader("Content-Disposition",
" attachment; filename=\"Design.pdf\"");
writer = PdfWriter.getInstance(document, response.getOutputStream());
document.open();
PdfContentByte cb = writer.getDirectContent();
Graphics2D graphics2D = cb.createGraphics(36, 54);
graphics2D.drawString("Hello World", 36, 54);
graphics2D.dispose();
document.close();
Run Code Online (Sandbox Code Playgroud)
我是否必须执行其他操作才能将图形添加到文档中,或者我的语法不正确?
我想通过比较一个来验证2个输入字段,并确保第二个输入字段大于第一个输入字段.
我是否需要添加自定义方法,还是只在范围方法中使用变量名称?如果是这样,你能指点我的语法吗?
var validateSection = function (theForm) {
$(theForm).validate({
rules: {
startPoint: {
required: true,
range: [0, 100]
},
endPoint: {
required: true,
range: [startPoint + 1, 100] //Is this possible if I set the function to run on any change to either field?
},
}
});
if ($(theForm).valid()) {
return true;
}
else {
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
自定义方法代码:
$.validator.addMethod("endGreaterThanBegin", function(value, element) {
return endPoint > startPoint
}, "* End Point Should be Greater than Start");
var validateSection = …Run Code Online (Sandbox Code Playgroud) 人们喜欢得到不同种类和数量的水果,我想帮助他们.我有一个看起来像这样的表:
name fruit count temp
-----------------------------
Jim apple 3 hot
Jim banana 7 cold
Jim orange 12 cold
Sam plum 5 hot
Sam peach 1 hot
Bob cherry 4 cold
Bob banana 11 hot
Bob orange 9 cold
Bob kiwi 6 hot
Run Code Online (Sandbox Code Playgroud)
每个人可能有1或1000行,我不知道提前了多少,所以我认为这需要动态列列表.我需要它看起来像这样:
name fruit_1 count_1 temp_1 fruit_2 count_2 temp_2 fruit_3 count_3 temp_3 fruit_4 count_4 temp_4
-------------------------------------------------------------------------------------------------------
Jim apple 3 hot banana 7 cold orange 12 cold null null null
Sam plum 5 hot peach 1 hot null null null …Run Code Online (Sandbox Code Playgroud) java ×2
spring-mvc ×2
graphics2d ×1
itext ×1
javascript ×1
jquery ×1
jsp ×1
jstl ×1
pivot ×1
sql ×1
sql-server ×1
t-sql ×1