Tag: http request parameters

Spring MVC – 为什么不能一起使用@RequestBody和@RequestParam

使用具有Post请求和Content-Type应用程序的HTTP dev客户端/ x-www-form-urlencoded 1)只有@RequestBody Request – localhost:8080 / SpringMVC / welcome在Body – name = abc中 码- @RequestMapping(method = RequestMethod.POST) public String printWelcome(@RequestBody String body, Model model) { model.addAttribute("message", body); return "hello"; } //如预期的那样给body赋予“name = abc” 2)只有@RequestParam Request – localhost:8080 / SpringMVC / welcome在Body – name = abc中 码- @RequestMapping(method = RequestMethod.POST) public String printWelcome(@RequestParam String […]

HTTP请求参数不能通过request.getAttribute()

我使用以下jQuery件发送一个url参数给servlet: $.getJSON("http://localhost:8080/JsoupPrj/JasonGen?url=" + url, function(data) { $("#content").html(data); }); 在服务器端,servlet获取参数,我编码如下: String url = (String) request.getAttribute("url"); 但是它不工作,你能告诉我我在做什么错吗? 我相信我没有正确地将parameter passing给servlet。 servlet每次都通过JavaScript触发,但是没有看到从浏览器传来的参数。

保留JSF表单提交的GET请求查询字符串参数

我有3页: main.xhtml agreement.xhtml generated.xhtml agreement.xhtml需要两个参数来正确加载: serviceId和site 。 所以,一个普通的url看起来像这样: /app/agreement.xhtml?site=US&serviceId=AABBCC 。 我在agreement.xhtml上有这个按钮 <h:form> <h:commandButton value="Generate License File" action="#{agreement.generateMethod}" /> </h:form> @RequestScoped bean #{agreement}有这个方法: public String generateMethod(){ ……. return "generated"; } 我需要的是,单击时,执行generateMethod()方法,完成后,用户被重定向到generated.xhtml页面。 发生的事情是,单击页面浏览器将用户发送到/app/agreement.xhtml ,因为它不发送参数site和serviceId ,它崩溃。 我试着让generateMethod()返回一个"generated?faces-redirect=true" ,但还是什么都没有。 有任何想法吗?