标签:set app lan 使用 out val 默认 开启 依赖
1 Maven引入依赖jar包:jstl.jar和standard.jar
<dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> <scope>runtime</scope> </dependency> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>1.1.2</version> </dependency>
页面中引入jstl 即
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
2.Jsp2.0一下版本默认不开启EL 所以需要在页面上添加 <%@ page isELIgnored="false" %>
<%@ page isELIgnored="false" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <html > ....
jsp2.0以上版本可以配置web.xml文件,默认开启EL
<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">
...
一个简单的Demo
<%--<%@ page isELIgnored="false" %>--%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %> <html> <body> <h2>Hello World!</h2> <h3> <c:out value="${name}"></c:out></h3> <h4> <c:out value="${age}"></c:out> </h4> 美女: <c:set var="motto" scope="session">约么</c:set> <c:out value="${motto}"></c:out> </body> </html>
@Controller @RequestMapping("/home") public class HomeController { @RequestMapping(value = "/index/{name}",method = RequestMethod.GET) public String Index(@PathVariable String name, @RequestParam String age, Model model ){ model.addAttribute("name",name); model .addAttribute("age",age); return "index"; } }
标签:set app lan 使用 out val 默认 开启 依赖
原文地址:http://www.cnblogs.com/ylsforever/p/7661453.html