Spring Mvc中Jsp也页面怎么会获取不到Controller中的数据

----------Controller -------

package com.test.mvc;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class GeneralController {
@RequestMapping(value="index.do")
public String index_jsp(Model model){
  model.addAttribute("test","你好!");
  System.out.println("index.jsp");
  return "index";
}
}

--------------index.jsp------------------
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>Insert title here</title>
</head>

<body>
  <cut value="${test}"></cut>
  ${test}
</body>
</html>

------------------结果输出---------------------
  ${test}   ${test}

-------------------修改内容----------------------
index.jsp 添加<%@ page isELIgnored="false" %>

结果正常显示:
你好 你好

时间: 2024-07-28 23:03:10

Spring Mvc中Jsp也页面怎么会获取不到Controller中的数据的相关文章

Spring MVC 以.html为后缀名访问获取数据,报406 Not Acceptable错误。

如题,最近以spring mvc作为后台框架,前端异步获取数据时(.html为后缀名的访问方式),报406 Not Acceptable错误.当初都不知道啥原因,前后台都没报错就是返回不了数据,于是查了下http 406响应码:406 (SC_NOT_ACCEPTABLE)表示请求资源的MIME类型与客户端中Accept头信息中指定的类型不一致.下面请看出错的操作流程及代码: 1.先配置spring mvc 核心servlet (DispatcherServlet) 至web.xml中,其中配置

spring mvc关于jsp页面传递到controller层参数类型转换(格式化)的学习记录--2018年1月

spring mvc jsp传递参数到controller涉及到日期类型数据,需要使用到类型转换器:目前笔者找到两种类型转换器可以使用: 类型一:实现Convert<Source,Target>接口的方式(Source源数据,Target目标数据类型),实现功能是一种数据类型到另一种数据类型:数据转换类如下:在不添加DateTimeFormatter.ofPattern("yyyy/MM/dd")时(MM必须大写,小写表示时间分),默认需要输入的String样式"

Spring mvc UEditor jsp版本

此文章主要解决在spring mvc 框架模式下面使用UEditor 图片或者文件上传成功读取不到的bug说明(主要已官方文档为主). 1.项目中应用UEditor.(jsp版本) 1.1参考官方 http://fex-team.github.io/ueditor/  中jsp使用说明. 2.结合Spring mvc 使用. 错误回顾,下图表示UEditor 引用成功,选择图片,图片不能正常显示,提示本地保存成功. 错误分析,启用firefox 的firebug 能看到一下图片 通过Everyt

Spring MVC通过Pageable对象和PageableDefault注解获取分页信息(MongoDB通过Pageable来操作分页)

说明:Pageable同时也能用于操作MongoDB的分页. PageableSpring Data库中定义的一个接口,该接口是所有分页相关信息的一个抽象,通过该接口,我们可以得到和分页相关所有信息(例如pageNumber.pageSize等). Pageable定义了很多方法,但其核心的信息只有两个:一是分页的信息(page.size),二是排序的信息. 在Spring MVC的请求中只需要在方法的参数中直接定义一个Pageable类型的参数,当Spring发现这个参数时,Spring会自动

bug Spring Mvc中Jsp页面获取不到Controller中的变量

今天遇到了一个奇怪的问题: jsp代码如下: <h1>数据对比${name}</h1> 在controller里面,有赋值: @RequestMapping(value = "/index.do") public String index(ModelMap modelMap) { modelMap.put("name", "test"); return "/compare/index"; } 但是死活不

spring mvc 整合jsp和thymeleaf两个模板引擎

代码地址 http://github.com/dingxiaobo/multi-view-resolver 分别用两个dispatcher分别解析jsp页面和thymeleaf页面 pom.xml ... <!--thymeleaf--> <!-- https://mvnrepository.com/artifact/org.thymeleaf/thymeleaf --> <dependency> <groupId>org.thymeleaf</gro

spring mvc的工程遇到页面加载jquery失败,提示 ReferenceError: $ is not defined

测试页面代码: <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script><title>首页</title><script type="text/javascript"> $().ready(function(){        alert("test");    }); </scr

spring mvc 跳转后页面cs样式表丢失

原因:../不能正确返回 解决办法:jsp文件加<% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> 样式表地址采用<%=path %>/替换../ 例:<link hr

Spring MVC (Java),强制页面不缓存

response.setDateHeader("Expires",0);        response.setHeader("Buffer","True");        response.setHeader("Cache-Control","no-cache");        response.setHeader("Cache-Control","no-store&qu