简体   繁体   中英

How to refresh in JSP after updating data

The pages of my web application import a file called header.jsp , this file sets the user name at the top of the site. When I update the user's email , but I can only see changes occur logout and then login. 但是我只能看到更改发生注销并登录。
I guess it's caused because of this header, how do I " update it"?

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>
                            &nbsp;
                        </li>

                        <li class="check">
                            <button onclick="cadastro();">Atualizar</button>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <script>

结合使用javascript和ajax来更新所需的html元素

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM