当前位置: 代码迷 >> Java Web开发 >> JSP <%= %> 语法有关问题
  详细解决方案

JSP <%= %> 语法有关问题

热度:6978   发布时间:2013-02-25 21:10:56.0
JSP <%= %> 语法问题
最近才开始学,就想请问上面这句话到底是啥子意思,我去找了找生成的java文件,里面是写成了out.print(xx),有人说这个可以拿来获取变量的值,求高人指教

------解决方案--------------------------------------------------------
给你看代码例子:
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String currentDate = sdf.format(new Date());

%>


....然后在jsp其他地方
<tr>
<td>拟&nbsp;&nbsp;稿&nbsp;&nbsp;人:</td>
<td><input type="text" name="draftsman"
value="<%=session.getAttribute("userName")%>"></td>
<td width="40">拟稿日期:</td>
<td><input type="text" name="createDate"
value="<%=currentDate%>" readonly></td>
</tr>
  相关解决方案