亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么JSP頁面引用不到tag文件中variable指令返回的對象,已遇到多次,求解答,謝謝!

為什么JSP頁面引用不到tag文件中variable指令返回的對象,已遇到多次,求解答,謝謝!

_愛吃貓的魚 2015-11-16 15:44:50
inputNumber.jsp頁面代碼<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%@ taglib tagdir="/WEB-INF/tags" prefix="computer" %><html><body><h2>輸入運算數、選擇運算符號:</h2><form action="" method="post"><input type="text" name="num1" /><select name="operator"><option value="+">+<option value="-">-<option value="*">*<option value="/">/</select><input type="text" name="num2" /><br /><br /><input type="submit" value="提交你的選擇"/></form><% request.setCharacterEncoding("utf-8"); String a = request.getParameter("num1"); String b = request.getParameter("num2"); String operator = request.getParameter(operator); if(a==null) a=""; if(b==null) b=""; if(a.length()>0&&b.length()>0){%><computer: Computer numberA="<%=a %>" numberB="<%=b %>" operator="<%=operator %>" />計算結果:<%=a %><%=operator %><%=b %><%=result %><%}%></body></html>Computer.tag頁面代碼<%@ tag pageEncoding="utf-8" %><%@ attribute name="numberA" required="true" %><%@ attribute name="numberB" required="true" %><%@ attribute name="operator" required="true" %><%@ variable name-given="result" scope="AT_END" %><% try{ double a = Double.parseDouble(numberA); double b = Double.parseDouble(numberB); double r = 0; if(operator.equals("+")) r=a+b; if(operator.equals("-")) r=a-b; if(operator.equals("*")) r=a*b; if(operator.equals("/")) r=a/b; jspContext.setAttribute("result", String.valueOf(r)); }catch(Exception e){ jspContext.setAttribute("result", "發生異常:"+e); }%>
查看完整描述

1 回答

?
qq_shoulder_23344064

TA貢獻2條經驗 獲得超0個贊

我也遇到了這種情況了,請問你是如何解決的,在線等

查看完整回答
反對 回復 2016-05-11
  • 1 回答
  • 0 關注
  • 3833 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號