传统上,要在页面加载后调用JavaScript函数,您onload
需要向包含一些JavaScript(通常只调用函数)的主体添加一个属性:
<body onload="foo()">
Run Code Online (Sandbox Code Playgroud)
当页面加载完毕后,我想运行一些JavaScript代码,用来自服务器的数据动态填充页面的各个部分.我不能使用该onload
属性,因为我正在使用JSP片段,它没有body
可以添加属性的元素.
还有其他方法可以在加载时调用JavaScript函数吗?我宁愿不使用jQuery,因为我对它不是很熟悉.
我希望有人在这个问题中解释一下BlausC的惊人答案.
他说小脚本有一些缺点,它们是:
可重用性:您无法重用scriptlet.我的问题:我怎样才能重用JSTL代码?
可替换性:您不能使scriptlet抽象化.抽象是什么意思,JST如何变得抽象?
OO:你不能利用继承/组合.我如何在JSTL中使用OO范例?
调试:如果一个scriptlet中途抛出异常,你得到的只是一个空白页面.
可测试性:scriptlet不能进行单元测试.这是什么意思,JSTL如何进行单元测试?
可维护性:每个saldo,需要更多的时间来维护混杂/混乱/重复的代码逻辑.这是什么意思?
最后一件事是他引用甲骨文的建议:
JSP scriptlet不应该用于编写业务逻辑.
在MVC模式中,我仅在表示层中使用scriptlet.他在这里是什么意思?
我想获取具有specfic值的复选框并进行检查..
我是这样做的
$(":checkbox").filter({"value":5}).attr("checked","true");?
Run Code Online (Sandbox Code Playgroud)
这是html
?<input type="checkbox" name="priv"????????????????????????????? value="1"?????????????????/>
<input type="checkbox" name="priv" value="2"/>
<input type="checkbox" name="priv" value="3"/>
<input type="checkbox" name="priv" value="4"/>
<input type="checkbox" name="priv" value="5"/>
<input type="checkbox" name="priv" value="6"/>
<input type="checkbox" name="priv" value="7"/>
<input type="checkbox" name="priv" value="8"/>?
Run Code Online (Sandbox Code Playgroud)
这是一个问题的演示
我想让这些元素中的每一个都是不同的行,而不是<br />
在HTML中使用,<h1>
是块元素但我必须修复它width
.我怎样才能让锚点<h1>
不在旁边呢?
<h1 id="viewerTitle">Header </h1>
<a href="#" class="view-options">View options</a>
<a href="#" class="view-options">View options</a>
Run Code Online (Sandbox Code Playgroud)
这是一个例子:http://jsfiddle.net/mmhhd/
我正在研究AES算法,我有这个例外,我无法解决.
javax.crypto.BadPaddingException: Given final block not properly padded
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.AESCipher.engineDoFinal(DashoA13*..)
at javax.crypto.Cipher.doFinal(DashoA13*..)
Run Code Online (Sandbox Code Playgroud)
异常发生在解密部分.我在与解密算法不同的地方初始化密钥
KeyGenerator kgen = KeyGenerator.getInstance("AES");//key generation for AES
kgen.init(128); // 192 and 256 bits may not be available
Run Code Online (Sandbox Code Playgroud)
然后我用我从文件中读取的密文传递给下面的方法
public String decrypt(String message, SecretKey skey) {
byte[] raw = skey.getEncoded();
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
// Instantiate the cipher
Cipher cipher;
byte[] original = null;
try {
cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
System.out.println("Original string: "
+ message);
original = cipher.doFinal(message.trim().getBytes()); //here where I …
Run Code Online (Sandbox Code Playgroud) 我想用CSS创建一个循环扇区.这些部门将形成一个完整的圈子.我怎样才能使用CSS?
我找到了一个样本,但它制作了四分之一的圆形扇区.我想制作一个完整圆圈的六个圆形扇区.我该怎么做?
注意:我不擅长绘画,但这里有我想要的样本......
div {
width: 50px;
height: 50px;
background-color: #ccc;
background-color: #ccc;
-moz-border-radius: 100px;
border-radius: 100px;
}
#center {
position: relative;
margin: 100px 0 0 100px;
border: solid #fff 1px;
}
#tl,#tr,#bl,#br {
position: absolute;
height: 75px;
width: 75px;
z-index: -1;
}
#tl {
border-radius: 100px 0 0 0;
-moz-border-radius: 100px 0 0 0;
top: -50px;
left: -50px;
}
#tr {
border-radius: 0 100px 0 0;
-moz-border-radius: 0 100px 0 0;
top: -50px;
left: 26px;
}
#bl …
Run Code Online (Sandbox Code Playgroud)我想将对象数组转换为json编码,我这样做
$allVisits = $mapper->getAllVisits($year, $month);
echo json_encode($allVisits);
Run Code Online (Sandbox Code Playgroud)
这是getAllVisists方法
function getAllVisits($year, $month) {
$where = array(
'year = ?' => $year,
'month = ?' => $month
);
$resultSet = $this->getDbTable()->fetchAll( $where);
$visitsEntries = array();
foreach ($resultSet as $row) {
$entry = new Visits_Model_Visit();
$entry->setId($row->visit_id)
->setDay($row->day)
->setDate($row->date)
->setTarget($row->target)
->setStatus($row->visit_status)
->setTime($row->visit_time);
$visitsEntries[] = $entry;
}
return $visitsEntries;
}
Run Code Online (Sandbox Code Playgroud)
当我回显$ allVisits的大小时,它返回正确的记录数,但是在js中,这些值是空的,如[{},{},{},{}]
编辑
当我对print_r($ allVisists)进行编码时,它会返回
Array
(
[0] => Visits_Model_Visit Object
(
[day:private] => sunday
[date:private] => 2012-03-06
[target:private] => ???
[id:private] => 1
[status:private] …
Run Code Online (Sandbox Code Playgroud) 我想从java发送两个数组到oracle存储过程.第一个数组是字符串数组,第二个是字符数组,我该如何制作?
我可以从中获取请求的URL ajaxStart
吗?我想为所有ajax请求执行一个公共操作,接受一些请求.
我想将String转换为secretKey
public void generateCode(String keyStr){
KeyGenerator kgen = KeyGenerator.getInstance("AES");
kgen.init(128); // 192 and 256 bits may not be available
// Generate the secret key specs.
secretKey skey=keyStr; //How can I make the casting here
//SecretKey skey = kgen.generateKey();
byte[] raw = skey.getEncoded();
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用BASE64Decoder而不是secretKey,但我面临的一个问题是我无法指定密钥长度.
编辑: 我想从另一个地方调用此功能
static public String encrypt(String message , String key , int keyLength) throws Exception {
// Get the KeyGenerator
KeyGenerator kgen = KeyGenerator.getInstance("AES");
kgen.init(keyLength); // 192 and 256 bits may not be available
// Generate …
Run Code Online (Sandbox Code Playgroud) java ×4
css ×2
encryption ×2
html ×2
jquery ×2
checkbox ×1
cryptography ×1
css-shapes ×1
encoding ×1
exception ×1
javascript ×1
json ×1
jsp ×1
jstl ×1
onload ×1
oracle ×1
php ×1