问题描述
我有一个文本字段,只允许在Struts2中粘贴数字.我尝试在文本字段中使用onPaste
属性,但它抛出异常
I have a textfield which should allow pasting only numbers in Struts2.I tried using onPaste
attribute in textfield but it throws below exception
org.apache.jasper.JasperException:
/WEB-INF/**.jsp Attribute onPaste invalid for tag textfield according to TLD
在没有粘贴事件的情况下是否可以执行上述功能?
Is there anyway to do above function without paste event?
推荐答案
Struts 2.0中不允许使用动态属性.您应该升级到最新版本.目前 2.3.20 可用.
Dynamic attributes not allowed in Struts 2.0. You should upgrade to the latest version. Currently 2.3.20 is available.
onpaste
是一个HTML属性,用于将事件处理程序动态绑定到该元素.但是您也可以使用jQuery代码手动完成
onpaste
is a HTML attribute to dynamically bind the event handler to the element. But you can also use a jQuery code to do it manually
$("input[type=text]").on("paste", function() {
return isAllowNu();
});
它将处理所有input
文本元素的paste
事件. texfield
正在生成这些HTML标签.
It will handle paste
event for all input
text elements. The texfield
s are generating these HTML tags.
这篇关于Javascript粘贴事件以允许Struts 2中的数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!