日期:2014-05-17  浏览次数:20735 次

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>