为什么不对呢?
package com.imooc.jstl;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class Jstlc
*/
@WebServlet("/js")
public class Jstlc extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Jstlc() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("set", 5);
request.getRequestDispatcher("/jstl.jsp").forward(request, response);
}
}<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<c:if test="${set>0&&(set<=10)}">
<h2 style="color:blue;">1-10之间的整数</h2>
</c:if>
<c:if test="${set>10&&(set<=20)}">
<h2 style="color:red">10-20之间的整数</h2>
</c:if>
</body>
</html>
3
收起
正在回答 回答被采纳积分+1
2回答
慕田峪1061482
2019-09-25 14:03:37
为什么我自己编写servlet程序时,那个映射地址没有显示出来,而跟着老师视频写servlet的时候映射地址才会显示出来?
2. 从网页搭建入门JavaWeb
- 参与学习 人
- 提交作业 676 份
- 解答问题 9666 个
本阶段将从前端网页搭建入手,到Java Web基础,前后端结合助你完成Java Web小白的蜕变!
了解课程


恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星