多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
FollowServlet.java ~~~ package zyw.JSP; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @WebServlet(name = "FollowServlet",urlPatterns = "/follow") public class FollowServlet extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String follow=request.getParameter("follow"); request.setAttribute("follow",follow); request.getRequestDispatcher("/jstl/jstl.jsp").forward(request,response); } } ~~~ jstl/jstl.jsp ~~~ <%-- Created by IntelliJ IDEA. User: Administrator Date: 2018/7/14 Time: 16:08 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <html> <head> <title>Title</title> </head> <body> <%--使用JSTL的时候需要配合EL表达式--%> <c:if test="${requestScope.follow eq 1}"> 取消关注 <%--如果test等于true 则会执行内部代码,如果是false则不会执行内部代码--%> </c:if> <c:if test="${requestScope.follow eq 0}"> 关注 <%--如果test等于true 则会执行内部代码,如果是false则不会执行内部代码--%> </c:if> </body> </html> ~~~ ![](https://box.kancloud.cn/2da68a28a4a87d5d4ab7d245b582c7e5_592x97.png) ![](https://box.kancloud.cn/c933090f6a48715f159d4913073adf2d_596x95.png)