您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Java怎么给jsp页面赋值

2025/11/25 18:33:38发布21次查看
使用转发来给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页面赋值的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product