您好,欢迎访问一九零五行业门户网

Java怎么给jsp页面赋值

使用转发来给jsp页面赋值。具体操作如下:
这个在servlet中可是使用转发实现参数传递
protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception {    // todo auto-generated method stub    request.setcharacterencoding(utf-8);    request.setattribute(username, dhweicheng);    request.setattribute(password, 123456);    request.getrequestdispatcher(/my.jsp).forward(request, response);}
jsp页面代码:
<%@ page language="java" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%><!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"><html>    <head>        <meta http-equiv="content-type" content="text/html; charset=utf-8">        <title>页面代码</title>    </head>    <body>        <h5>通过request对象取值</h5>        账号:<%=request.getattribute("username") %>        密码:<%=request.getattribute("password") %>        <p>=======================</p>        <h5>通过el表达式取值</h5>        账号:${username}        密码:${password}    </body></html>
以上就是java怎么给jsp页面赋值的详细内容。
其它类似信息

推荐信息