格式不对是怎么个不对法呢
答案:
用命令把springframework.log内容中的关键词springframework替换成noperson
INFO: Attempt #1 to do the action check updates server
Oct 24, 2019 8:42:22 PM org.springframework.context.support.AbstractApplic
INFO: Refreshing org.springframework.web.context.support.StaticWebApplicat
icationContext]; startup date [Thu Oct 24 20:42:22 CST 2019]; root of cont
Oct 24, 2019 8:42:22 PM org.springframework.context.support.AbstractApplic
INFO: Bean factory for application context [org.springframework.web.contex
: org.springframework.beans.factory.support.DefaultListableBeanFactory@c9d
Oct 24, 2019 8:42:22 PM org.springframework.beans.factory.support.DefaultL
INFO: Pre-instantiating singletons in org.springframework.beans.factory.su
ing beans [authenticationManager]; root of factory hierarchy
Oct 24, 2019 8:42:23 PM org.springframework.context.support.AbstractApplic
INFO: Refreshing org.springframework.web.context.support.StaticWebApplicat
icationContext]; startup date [Thu Oct 24 20:42:23 CST 2019]; root of cont
Oct 24, 2019 8:42:23 PM org.springframework.context.support.AbstractApplic
INFO: Bean factory for application context [org.springframework.web.contex
: org.springframework.beans.factory.support.DefaultListableBeanFactory@1cb
Oct 24, 2019 8:42:23 PM org.springframework.beans.factory.support.DefaultL
INFO: Pre-instantiating singletons in org.springframework.beans.factory.su
ning beans [filter,legacy]; root of factory hierarchy
复制代码
根据参考资料中的思路,可以在拦截器中将需要展示的用户登录信息存入模板引擎中,然后在会员信息栏中直接调用即可。具体实现步骤如下:
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 获取用户登录信息,并存入模板引擎中
User loginUser = (User) request.getSession().getAttribute("loginUser");
if (loginUser != null) {
request.setAttribute("userName", loginUser.getName());
}
return super.preHandle(request, response, handler);
}
<div class="member-info">
会员信息: <span th:text="${userName}"></span>
</div>
其中,${userName}
为模板引擎中存储的用户登录名。
此外,如果出现会员信息格式不对的问题,可能是由于页面样式的问题。建议检查一下会员信息栏的html代码和样式表,以确保展示效果正确。
以上是具体的实现方法和优化建议,希望能对你有所帮助。