且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将变量从Servlet发送到JSP

更新时间:2022-11-26 13:28:41

请求参数从视图发送到控制器,请求属性用于在当前请求中传递数据,以帮助构建新的响应.因此,您 不应使用Scriplet ,而应使用表达语言:

Request parameters are sent from the view to the controller, request attributes are used to pass data in the current request to help build the new response. So, you should not use scriplets and access to the request attributes by using Expression Language:

<body>
    <!-- No need to use a form for this page -->
    The request attribute: ${var}
</body>

请注意,根据当前请求,您应该在servlet上执行GET请求.由于您的servlet名称是 servlet (我建议您立即更改它),因此您应该访问以下URL:http://yourServerName/yourApplicationName/servlet

Note that by your current request, you should perform a GET request on your servlet. Since your servlet name is servlet (which I suggest your to change it immediately), you should access to this URL: http://yourServerName/yourApplicationName/servlet