package classes;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.joda.time.DateTime;
public class MyListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent sce) {
System.out.println("Project deployed: " + new DateTime());
//or any other form of output
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
System.out.println("Project undeployed: " + new DateTime());
//or any other form of output
}
}
我将'e'作为字符串EnumTypeA而不是1.我应该如何传递它以将其作为整数?
答案 0 :(得分:3)
因为data-enum
属性值是"字符串",不是对象或对象变量或整数或...
执行此迁移可以帮助您:
<p data-enum=EnumTypeA> </p>
var NewEnum= { EnumTypeA: 1 }
var e = $(this).data('enum');
var eint = parseInt(NewEnum[e]);
修改强>
以下是一个显示其工作原理的摘录:
var NewEnum= { EnumTypeA: 1 }
function getInt(p) {
var e = p.getAttribute('data-enum');
var eint = parseInt(NewEnum[e]);
var chkvalue = document.getElementById("chkvalue");
chkvalue.innerHTML = "The enum values is: " + eint;
}
&#13;
<p onclick="getInt(this);" data-enum=EnumTypeA> Click here </p>
<p id="chkvalue"> </p>
&#13;