今天寫web項目作業時,發現jsp中“Cannot return from outside a function or method” 提示return出錯,百度了一下,網上說這是myeclipse的一個bug,去掉return就好了,去掉之後果然不報錯,但是之後發現onSubmit()不能阻止表單送出,再百度之,原來這個return還真不能去掉。
以下就是今天錯誤的解決方法
1.jsp網頁出現“Cannot return from outside a function or method” 提示return出錯
window –>preferences –>myeclipse –>validation –>javascript validator for Js files 把Bulid 複選框的勾去掉,
myeclipse 重新開機之後便生效
2.onSubmit(), false 仍然跳轉,onSubmit=”return checkForm()” ,onsubmit屬性中要寫”return checkForm()”,而不僅僅是
” checkForm()”