求助!!!!!!!!!!JSP页面可以识别session不可以识别model传递的值

哈哈哈也不行吗 2019-06-19 11:56:45
1.Session传值是可以获取的,但是model.addAttribute("a",a)这种形式却传递不了,最可恶的是网页的url都显示了a的值,但是网页对应部分却显示空白


这是Controller部分代码:
if(signService.addGetup(userid, recordtime,recordday)==true){//添加日期
System.out.println("11111111111111111111111111");
userService.addGetupCount(userid);
System.out.println("添加次数成功");
String message = "";
message = "叮~早起卡";
model.addAttribute(Constants.GETUP_SESSION, signService.selectGetupInfo(userid, recordday));
System.out.println(signService.selectGetupInfo(userid, recordtime).getRecordtime());
request.getSession().setAttribute("mes", message);
//model.addAttribute(Constants.GETUP_SESSION, getup);

return "mainpage";
}
这是jsp页面代码:
<div class="user-pto ">
<a href="# " target="_blank " class="user-avatar " link="# " data-clicklog="avatar ">
<img src="${pageContext.request.contextPath }/statics/img/getup.jpeg " />
</a>
</div>
<div >
<span target="_blank " class="clearfix " link="# " data-clicklog="# " style="margin-left:20px;margin-top: 5px;margin-bottom: 5px;font: "微软雅黑"; ">
${userSession.username}
</span>
</div>
</div>
<div>
<label for="sign_time">打卡时间:${getupSession}</label>
</div>
<div>
<label for="sign_count">打卡天数:${userSession.getup}</label>
</div>


...全文
100 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
其他疑问:
①Added model object 'org.springframework.validation.BindingResult.user' of type [org.springframework.validation.BeanPropertyBindingResult] to request in view with name 'mainpage',我不明白我传递Model的时候为什么会出现这个语句
②我使用 <%=request.getAttribute("GETUP_SESSION.recordtime")%>替换${}后发现是null值
  • 打赏
  • 举报
回复
还有我的思路是这样的:用户信息在登录时通过session传递,用户签到后controller进行签到信息的查询并通过model传递,在jsp页面使用el表达式获取,但是:①签到信息不显示 ②用户信息在签到时也有一定的改变,但是不会更新(我知道这和session有关系),所以我想知道该怎么解决
因为是初学者,有提问的不合逻辑的地方,还请多多包涵和告知
下面是页面设置:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>

web.xml为3_1.xsd:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">

这是mvc对应的设置:2.5xsd
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
牛肉滚蛋花 2019-06-20
  • 打赏
  • 举报
回复
https://blog.csdn.net/yanheng0130/article/details/72773620 答案在这篇文章里
  • 打赏
  • 举报
回复
已解决,换成了session.setAttribute即可,但是其中的原理我还是不懂,所以还希望看见的大佬可以答疑。
现在要搞定信息更新的事儿啦
  • 打赏
  • 举报
回复
引用 3 楼 牛肉滚蛋花 的回复:
https://blog.csdn.net/yanheng0130/article/details/72773620
答案在这篇文章里

我前面的jsp页面上有写这个语句

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧