声明和调用在这里:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>#{msgs.windowTitle}</title>
<h:outputScript library="javascript" name="Resources/js/checkPassword.js" />
</head>
<body>
<h3>#{msgs.Entrance}</h3><br/><br/><br/>
<h:form>
<h:panelGrid columns="2" columnsClasses="evenColumns, oddColumns">
#{msgs.namePrompt}
<h:inputText/>
#{msgs.PasswordPrompt}
<h:inputSecret id="password" />
#{msgs.ConfirmPasswordPrompt}
<h:inputSecret id="passwordConfirm"/>
</h:panelGrid>
<h:commandButton type="button" value="Submit" onclick="checkPassword()" />
</h:form>
</body>
</html>
checkpassdword.js
function checkPassword(){
alert("here it is");
var password = form[form.id+":passwordConfirm"].value;
var passwordConfirm = form[form.id+":password"].value;
if(password==passwordConfirm){
form.submit();
}
else{
alert("Wrong");
}
}
位于WebContent/Resources/js
当我用put编写时,单击按钮,没有任何反应。
在资源管理器中,错误在控制台中
<script src="RES_NOT_FOUND" type="text/javascript"></script>
我该如何解决这个问题?我试图输入src,webinf,meta inf并试图声明src不是名字但没有发生任何事情。
错误未识别的checkPassword。
答案 0 :(得分:0)
替换
<h:outputScript library="javascript" name="Resources/js/checkPassword.js" />
带
<h:outputScript name="js/checkPassword.js"/>
并将您的WebContent中的Resources
文件夹重命名为resources
并查看以下主题What is the JSF resource library for and how should it be used?