简体   繁体   中英

JSP 2 Expression Language

I read tutorials at courses.coreservlets.com (it is on a PDF file so I cannot directly link the exact part of the topic). On JSP 2 Expression Language topic, the author shows comparison between JSP 1.2 and JSP2.

On JSP 1.2:

<BODY>
<jsp:useBean id="randomNum"
             type="coreservlets.NumberBean"
             scope="request" />
<H2>Random Number:
<jsp:getProperty name="randomNum"
                 property="number" />
</H2>
</BODY></HTML>

On JSP 2:

<BODY>
<H2>Random Number:
${randomNum.number} 
</H2>
</BODY></HTML>

randomNum is just a variable name of NumberBean class right? On JSP 1.2 it shows, but on JSP2 its just a one line.

My question is on JSP 2 how will server know that randomNum is NumberBean because I did not see any part of the code that will tell that randomNum is NumberBean?

I hope I made question clear.

它不知道,实际上它是在评估EL表达式时在任何范围内搜索页面上下文以找到名称为randomNum的变量。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM