JSP中获取参数的3中方法

JSP中获取参数的3中方法

我们有时需要在jsp页面中获取request中的参数,然后根据这些参数决定页面的一些内容或者动作。通常我们通过equest.getParameter(xxx);来获取,除了这种方式外,我们还可以通过param或者js来实现。

通过EL中的param

EL中有很多内置对象,我们使用param就可以获取参数

JSP EL Implicit Objects:

The JSP expression language supports the following implicit objects:

Implicit object Description

pageScope Scoped variables from page scope

requestScope Scoped variables from request scope

sessionScope Scoped variables from session scope

applicationScope Scoped variables from application scope

param Request parameters as strings

paramValues Request parameters as collections of strings

header HTTP request headers as strings

headerValues HTTP request headers as collections of strings

initParam Context-initialization parameters

cookie Cookie values

pageContext The JSP PageContext object for the current page

//do something

或者你在js中这样

Name is


Name is <%=appName%>


运行效果

相关推荐