NutzCN Logo
问答 jsp页面的el不被解析
发布于 2418天前 作者 蛋蛋的忧伤 1553 次浏览 复制 上一个帖子 下一个帖子
标签:

我后台servlet里:

req.getRequestDispatcher("/WEB-INF/jsp/login.jsp").forward(req, resp);

转发到web-INF下的jsp,内容如下:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <title>登录</title>
    <style>.error{color:red;}</style>
</head>
<body>

<div class="error">${error}</div>
<form action="${pageContext.request.contextPath}/login" method="post">
    用户名:<input type="text" name="username"><br/>
    密码:<input type="password" name="password"><br/>
    <input type="submit" value="登录">
</form>

</body>
</html>

web.xml:

<web-app version="2.4" 
xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 

  <display-name>Archetype Created Web Application</display-name>
  
    <filter>
	    <filter-name>iniShiroFilter</filter-name>
	    <filter-class>org.apache.shiro.web.servlet.IniShiroFilter</filter-class>
	    <init-param>
	        <param-name>configPath</param-name>
	        <param-value>classpath:shiro.ini</param-value>
	    </init-param>
	</filter>
	<filter-mapping>
	    <filter-name>iniShiroFilter</filter-name>
	    <url-pattern>/*</url-pattern>
	</filter-mapping>
  
</web-app>

然后我浏览器将${error}等el表达式都解析为字符串,没有解析出值....请问为什么不生效?

2 回复

2.4默认不解析的,改成2.5

问题解决,大叔威武.

添加回复
请先登陆
回到顶部