我想将组合框的选定值传递给java方法。我看到的所有帖子都提到了使用HttpServletRequest和getParameter函数来传递值,但我的问题是,我需要将值作为传递给Java方法的字符串,它已经存在。任何指针如何做到这一点? 我已经看到了doPost方法的一些参考,但这对我没有帮助,因为我需要的是传递给自定义java方法并使用它的值。任何帮助将深表感谢。我坚持了几个小时。
如有任何澄清或额外信息,请告知我们。
<SCRIPT>
function sendParam(){
var item= document.Form.item[document.Form.item.selectedIndex].value
//I need to send this value to the server side java code and process further
}
</SCRIPT>
答案 0 :(得分:0)
我通过动作课做到了。
<SCRIPT>
function sendParam(){
var item= document.Form.item[document.Form.item.selectedIndex].value
//I need to send this value to the server side java code and process further
var url = "/urlToActionClass"
document.Form.acton = url;
document.Form.submit();
}
</SCRIPT>
现在将值传递给java,我在action类中读取并在必需的Java函数中使用它。