是否可以在不使用scriptlet的情况下在JSTL表达式语言(EL)中创建日期值?这是我试图重构的一些遗留代码的片段,仅用于使用EL。
<td><%=new java.text.SimpleDateFormat("MM/dd/yyyy HH:mm z").format(new java.util.Date())%></td>
显然它打印出当前的日期和时间。我知道我可以使用EL格式化日期,但是我可以使用EL获取日期吗?
答案 0 :(得分:21)
我认为你不能在EL中这样做。但是这个怎么样,这里没有scriptlets
<jsp:useBean id="today" class="java.util.Date" scope="page" />
<fmt:formatDate value="${today}" pattern="MM.dd.yyyy" />
答案 1 :(得分:1)
如果您使用spring webflow框架
,那将会有所帮助如果你在flow.xml上定义它
$array = array();
$rsa = $wpdb->get_results("SELECT * from wp_letter ORDER BY l_name ASC");
foreach($rsa as $rrr)
{
array_push($array,$rrr->l_name);
}
$temp = 0;
foreach($array as $as)
{
$temp = 0;
$query = $wpdb->get_results("SELECT * FROM wp_term_taxonomy AS tx, wp_terms AS trm WHERE taxonomy = 'category' AND trm.term_id = tx.term_id AND name like '".$as."_%' ORDER BY name ASC");
foreach($query as $row1)
{
if($temp == 0)
{
echo '<h4>'. $as.'</h4>';
$temp = 1;
}
?>
<a class="anchor" href="<?php echo esc_url(get_category_link($row1->term_id)); ?>"><?php echo $row1->name;?></a><br/>
<?php }
} ?>
你可以得到像这样的价值
public class TestBench implements ApplicationListener {
public static final String VERT_SHADER =
"attribute vec2 a_position;\n" +
"attribute vec4 a_color;\n" +
"uniform mat4 u_projTrans;\n" +
"varying vec4 vColor;\n" +
"void main() {\n" +
" vColor = a_color;\n" +
" gl_Position = u_projTrans * vec4(a_position.xy, 0.0, 1.0);\n" +
"}";
public static final String FRAG_SHADER =
"#ifdef GL_ES\n" +
"precision mediump float;\n" +
"#endif\n" +
"uniform vec4 aTest;\n" +
"varying vec4 vColor;\n" +
"void main() {\n" +
" gl_FragColor = vColor;\n" +
"}";
public void create() {
mesh = new Mesh(true, MAX_VERTS, MAX_INDICES,
new VertexAttribute(VertexAttributes.Usage.Position, POSITION_COMPONENTS, "a_position"),
new VertexAttribute(VertexAttributes.Usage.ColorUnpacked, COLOR_COMPONENTS, "a_color"));
}
public void render() {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
Gdx.gl.glClearColor(0, 0, 0, 1);
flush();
}
void flush() {
mesh.setVertices(vertices);
mesh.setIndices(indices);
Gdx.gl.glDepthMask(false);
Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
shader.begin();
shader.setUniformMatrix("u_projTrans", camera.combined);
mesh.render(shader, GL20.GL_TRIANGLES, 0, vertices.lenght);
shader.end();
Gdx.gl.glDepthMask(true);
}
}