##SpringMVC框架中如果选用EL表达式,那么为什么报错?

在SpringMVC框架中,可能我们会利用El表达式来获取当前工程名,可是竟然报错?

   <a href="user/testController?username=hehe">请求测试1</a>
    <a href="/user/testController?username=haha&password=123">请求测试2</a>
    <a href="${pageContext.request.contextPath}/user/testController?username=haha&password=123">请求测试3</a>

可以看到我们上面的代码没问题,但是为什么选择请求测试3的时候,会报错呢?

  异常:

<%--[/$%7BpageContext.request.contextPath%7D/user/testController] in DispatcherServlet with name 'DispatcherServlet'--%>
后来才知道,在jsp中,如果选用这种格式,那么jsp的头部会有这样的一个属性:
isELIgnored="false",代表什么意思呢?

如果设定为真,那么JSP中的表达式被当成字符串处理。比如下面这个表达式${2000 % 20}, 在isELIgnored="true"时输出为${2000 % 20},
而isELIgnored="false"时输出为100。Web容器默认isELIgnored="false"。
所以我们建议在jsp的头部加上isELIgnored="false"的属性,这样我们的EL表达式就可以使用了
原文地址:https://www.cnblogs.com/liurui-bk517/p/11357173.html