Java – JSP, get and post parameters

I need to do some small tasks with JSP; It's a very new JSP. I wonder if it's possible to get only get or only post parameters from HTTP requests

I saw ServletRequest Getparameter (and aliases), but it seems that these methods get get and post parameters Is there any way to get only one of them instead of parsing the URL or request body yourself? If not, does the value of any priority rule override which (for example, the post parameter always overrides the get parameter)?

Solution

In general, requests should be better handled in servlets They have doget (request, response) and dopost (request, response) methods to distinguish the two

If you really insist on doing this in the JSP, you can use request Getmethod () distinguishes methods It will return get or post

Since this is homework, I want to learn how to use servlets and their DOX methods, so do it

Update: you can get the query string (request. Getquerystring()), which is just a get parameter, and parse it, but I won't say it's a common and good practice

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>