我的Web应用程序的页面导入名为header.jsp
的文件,此文件将用户名设置在站点的顶部。当我更新用户的电子邮件时,它已在数据库中正确更新但我只能看到更改发生登出然后登录。我想这是因为这个标题引起的,我该如何"更新它"?
header.jsp中
<%@ page import="oknok.entities.Instancia" %>
<%@ page import="oknok.entities.User" %>
<%@ page import="oknok.utils.PropertiesSingleton" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%
String nome = null;
String perfil = null;
String instancia = null;
String categoriaInstancia = null;
String email = null;
String empresa = null;
String token = null;
Instancia instanciaObj = null;
if (request.getAttribute("user") !=null) {
nome = ((User) request.getAttribute("user")).getNome();
perfil = ((User) request.getAttribute("user")).getPerfil();
instancia = ((User) request.getAttribute("user")).getInstancia().get(0);
categoriaInstancia = ((User) request.getAttribute("user")).getCategoria();
email = ((User) request.getAttribute("user")).getEmail();
empresa = ((User) request.getAttribute("user")).getEmpresa();
instanciaObj = ((Instancia) request.getAttribute("instancia"));
token = ((User) request.getAttribute("user")).getToken();
}
%>
HTML
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="../headdefault.jsp" %>
<%@ include file="header.jsp" %>
<div id="container">
<div id="content">
<h2 class="noicon">Editar perfil</h2>
<div class="colform">
<ul>
<li>
<label for="usuario">Nome</label>
<input maxlength="30" type="text" id="usuario" name="usuario" value='<%= nome %>'/>
</li>
<li>
<label for="email">Email</label>
<input maxlength="120" type="text" id="email" name="email" value='<%= email %>' disabled="disabled"/><span id="aviso-email"></span>
</li>
<li>
<label for="empresa">Empresa</label>
<input maxlength="30" type="text" id="empresa" name="empresa" value='<%= empresa
%>'/>
</li>
<li>
<label for="senha">Senha Atual</label>
<input maxlength="30" type="password" id="senha" name="senha" />
</li>
<li>
<label for="novasenha">Nova Senha</label>
<input maxlength="30" type="password" id="novasenha" name="novasenha"/>
</li>
<li>
<label for="confirmarnovasenha">Confirmar Nova Senha</label>
<input maxlength="30" type="password" id="confirmarnovasenha" name="confirmarnovasenha"/>
</li>
<li >
<div id="errosform">
</div>
</li>
<li>
</li>
<li class="check">
<button onclick="cadastro();">Atualizar</button>
</li>
</ul>
</div>
</div>
</div>
<script>
答案 0 :(得分:0)
使用带有ajax的javascript来更新所需的html元素