public String getVatNetAmount()
{
String expensetype = getRequest().getParameter("type");
String localAmount = getRequest().getParameter("amount");
Double localamt = Double.parseDouble(localAmount);
Double netAmount;
netAmount = getExpensesTypeManager().getVatNetAmount(expensetype,localAmount);
am = (float) ((localamt * netAmount)/100);
// getRequest().setAttribute("NetAmount", am);
return INPUT;
}
这是我的java类方法,我想在jsp页面或javascript函数中获取变量am
中的数据?
答案 0 :(得分:0)
您可以这样使用:
<%
String var="sth";
%>
<script>
var value = "<%=var%>";
</script>
答案 1 :(得分:0)
在Spring MVC中,您可以使用
将模型添加到jspModelAndView mv = new ModelAndView();
mv.addObject("keyForJsp",object); // you can get data in jsp by using the key "keyForJsp"
现在用javascript获取它。 (使用JSTL lib)
<script>
var data = '${keyForJsp}';
</script>