spring RequestMethod.POST-请求方法'GET'不支持
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring RequestMethod.POST-请求方法'GET'不支持相关的知识,希望对你有一定的参考价值。
我尝试获取过滤器页面参数,并使用它通过自定义按钮jsp进行一些操作。我使用JFrame制作一个弹出窗口并为用户显示信息。但是问题是我有一个java.awt.HeadlessException并导致500错误引发了我的网页。
这是摘录:
private void deploymentCoordinationFunc(FilterForm filterForm, String function) throw HeadlessException{
DeploymentPageFilter filter = new DeploymentPageFilter();
filter.setId(filterForm.getDeploymentId());
// Set all different parameters from filter
// make pop-up with message
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.pack();
frame.setVisible(true);
frame.dispose();
List<Long> ids = deploymentManager.getDeploymentsIdFiltered(filter);
List<Boolean> checks = new ArrayList<>();
float nbOfTrue;
float percentageAuthorize;
float percentagePlanned;
float lengthIds = ids.size();
switch (function){
case "checkAuthorize":
for (int i=1; i==lengthIds;i++){
checks.add(deploymentManager.checksAuthorizedAllowed(ids.get(i)));
}
nbOfTrue = Collections.frequency(checks, true);
percentageAuthorize = (nbOfTrue/lengthIds)*100;
LOGGER.info("check Authorize : "+checks.size()+" and percentage checked correctly:"+nbOfTrue);
JOptionPane.showMessageDialog(frame, "Check done ! Percentage of deployments correctly set : "+percentageAuthorize+"%.
If not 100%, be sure that all deployments filtered are in PLANNED status and be confirmed !");
case "checkPlan":
for (int i=1; i==lengthIds;i++){
checks.add(deploymentManager.checksPlannedAllowed(ids.get(i)));
}
nbOfTrue = Collections.frequency(checks, true);
percentagePlanned = (nbOfTrue/lengthIds) * 100;
LOGGER.info("Check Plan :"+checks.size()+" and percentage checked correctly"+nbOfTrue);
JOptionPane.showMessageDialog(frame, "Check done ! Percentage of deployments correctly set : "+percentagePlanned+"%.
If not 100%, be sure that all deployments filtered are in REQUEST status !");
case "authorizeDeployments":
for (int i=1; i==lengthIds;i++){
checks.add(deploymentManager.checksAuthorizedAllowed(ids.get(i)));
}
if (checks.size() == lengthIds){
for (int j=1; j == lengthIds; j++){
deploymentManager.authorizeDeployment(ids.get(j));
}
}
LOGGER.info("");
JOptionPane.showMessageDialog(frame, "Number of deployments PLANNED : "+checks.size());
case "planDeployments":
for (int i=1; i==lengthIds;i++) {
checks.add(deploymentManager.checksPlannedAllowed(ids.get(i)));
}
if (checks.size() == lengthIds){
for (int j=1; j ==lengthIds; j++){
deploymentManager.planDeployment(ids.get(j));
}
}
JOptionPane.showMessageDialog(frame, "Number of deployments PLANNED : "+checks.size());
}
}
@RequestMapping(value = {"/deployments/checkPlan.do"}, method = RequestMethod.POST)
public String checkPlanDeployment(@ModelAttribute("filterForm") FilterForm filterForm) {
deploymentCoordinationFunc(filterForm, "checkPlan");
return "redirect:/deployments/begin.do";
}
@RequestMapping(value = {"/deployments/checkAuthorize.do"}, method = RequestMethod.POST)
public String checkAuthorizeDeployment(@ModelAttribute("filterForm") FilterForm filterForm){
deploymentCoordinationFunc(filterForm, "checkAuthorize");
return "redirect:/deployments/begin.do";
}
@RequestMapping(value = {"/deployments/filterPlannedDeployments.do"}, method = RequestMethod.POST)
public String plannedDeployments(@ModelAttribute("filterForm") FilterForm filterForm){
deploymentCoordinationFunc(filterForm, "planDeployments");
return "redirect:/deployments/begin.do";
}
@RequestMapping(value = {"/deployments/filterAuthorizeDeployments.do"}, method = RequestMethod.POST)
public String authorizeDeployments(@ModelAttribute("filterForm") FilterForm filterForm){
deploymentCoordinationFunc(filterForm, "authorizeDeployments");
return "redirect:/deployments/begin.do";
}
我使用Weblogic 12.1.3,我读到weblogic和spring版本之间的链接,如果我不能避免此Exception,如何使弹出窗口提供用户消息。
答案
在不支持键盘,显示器或鼠标的环境中调用依赖于键盘,显示器或鼠标的代码时,将抛出HeadlessException。
您正在使用Java AWT JFrame,它与Spring MVC上的Windows应用程序有关。两者相互矛盾。JFrame-独立的Windows应用程序。Spring MVC-在浏览器上运行的Web应用程序。
另一答案
好,谢谢,我不知道。因此,要使用Spring MVC制作弹出窗口,我们不能使用JFrame。May最好在我的Controller和.jsp页面中设置不同的变量,如:
以上是关于spring RequestMethod.POST-请求方法'GET'不支持的主要内容,如果未能解决你的问题,请参考以下文章
错误 405 请求方法 'POST' 不支持 Spring Security