本文转自:https://www.vastyun.com/bloger/670.html
新建的 jsp 页面不像 eclipse 的页面一样有
<%String path = request.getContextPath();String basePath = request.getScheme() + "://" +request.getServerName() + ":" + request.getServerPort() + path + "/";%>
但手动添加以上代码时会报错,解决方法: 添加引用 javax.servlet-api-X.X.X.jar 到项目即可。具体方式可以参考上面链接。
要支持 EL 表达式,需要引用 jstl-1.2.jar 类库,然后就可以在 jsp 页面写这样的代码:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><c:choose> ???<c:when test="${not empty sessionScope.user}"> ???????欢迎你:${sessionScope.userName} ???</c:when> ???<c:otherwise> ???????你还没有登录,请先登录: ???????<form action="<%= path %>/login<%= path + "a" %>" method="post"> ???????????userName:<input type="text" name="userName" /><br /> ???????????password:<input type="password" name="password" /><br /> ???????????<input type="submit" value="登录" /> ???????</form> ???</c:otherwise></c:choose>
[转]IDEA 新建 JSP 项目时
原文地址:http://www.cnblogs.com/z5337/p/7482493.html