Home  >  Q&A  >  body text

java - JSP页面HTML标签中可以嵌入JSTL?

为什么在<input>标签中能写JSTL代码?

<input type="text" class="span12" name="loginname" autocomplete="off"                                                        <c:if test="${loginname!=null}">value="${loginname}"</c:if> placeholder="邮箱/用户名/已验证手机" /> 
阿神阿神2763 days ago807

reply all(4)I'll reply

  • 巴扎黑

    巴扎黑2017-04-18 09:24:46

    JSP标准标签库(JSP Standard Tag Library,JSTL)是一个JSP标签集合,它封装了JSP应用的通用核心功能。和JSP里面的标签是可以一起使用的,而JSP包含静态部分(标准的HTML标签、静态的页面内容等)和动态内容(Java程序控制的内容),实际上JSPServlet的一种特殊的形式,每一个JSP的页面就是一个Servlet的实例。所以在<input>标签里面加入JSTL代码,等同于完成一个完成的业务逻辑Servlet, the two can be used together.

    reply
    0
  • 高洛峰

    高洛峰2017-04-18 09:24:46

    Because the jsp file will be compiled into a java class by the servlet container when it is requested for the first time, the JSTL in it will be compiled and converted.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 09:24:46

    tomcat will read the jsp file and parse the non-html tags in the jsp. Like here, tomcat will read this <c:if test=></c:if> code and parse it with a parser (file header taglib corresponding class), in the final analysis, jsp will be converted into outputstream (standard html code) through tomcat compile to client (ie, ff, chrome)

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 09:24:46

    Jstl codes have a fixed format and writing method when writing. They will first be parsed by servlet containers such as tomcat to generate corresponding result data. This process occurs on the server side; while html tag parsing occurs on the browser side

    reply
    0
  • Cancelreply