在JSP页面上取java代码的参数

JAVA 代码:

HttpServletRequest request = ServletActionContext.getRequest();

HttpSession session = request.getSession();
    String message="error";
    session.setAttribute("message",message);

JSP页面:

<%
String str = (String)session.getAttribute("message");

 %>

<input type="hidden" name="str" value=<%=str %>>

 <script type="text/javascript">
  window.document.body.onload = function(){
  if((document.getElementById("str").value)=="error"){
      alert('用户不存在或密码不正确');
      }
  }
</script>

你可能感兴趣的:(java,jsp,String,function,session,input)