Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java HTTP状态405-不支持请求方法“GET”_Java_Spring_Hibernate_Jsp_Spring Mvc - Fatal编程技术网

Java HTTP状态405-不支持请求方法“GET”

Java HTTP状态405-不支持请求方法“GET”,java,spring,hibernate,jsp,spring-mvc,Java,Spring,Hibernate,Jsp,Spring Mvc,我想将付款添加到我的客户数据库中,但当我添加付款时,我发现此错误不受支持,我不知道问题出在哪里。你们能帮帮我吗 @Controller public class PaymentsController { @Autowired private UsersService usersService; @Autowired private PaymentsService paymentsService; @RequestMapping(value = "/ad

我想将付款添加到我的客户数据库中,但当我添加付款时,我发现此错误不受支持,我不知道问题出在哪里。你们能帮帮我吗

@Controller
public class PaymentsController {

    @Autowired
    private UsersService usersService;
    @Autowired
    private PaymentsService paymentsService;

    @RequestMapping(value = "/addPayments", method = RequestMethod.POST)
    public String addPayments(HttpServletRequest request, ModelMap map) {
        String user = request.getParameter("userId"); // this is the identifier for the user of this payment
        String transactName = request.getParameter("transactName");
        String paid = request.getParameter("paid");
        String unpaid = request.getParameter("unpaid");
        String balance = request.getParameter("balance");
        String total = request.getParameter("total");
        //.... get all other attributes you've passed from the form through request.getParameter("");

        //next, check whether or not a user with the userId from the screen exists in the db
        Users userObject = usersService.getUsers(user);
        //.getUsersByUserId(user);
        if (userObject != null) {
            // this means that we have a valid user to insert the payment to
            UsersPayments payment = new UsersPayments();
            payment.setUsers(userObject);
            payment.setTransactName(transactName);
            payment.setPaid(paid);
            payment.setUnpaid(unpaid);
            payment.setBalance(balance);
            payment.setTotal(total);
            //....  set the other properties of UsersPayment object

            paymentsService.addPayments(payment);
        }
        else {
            // you have an error right here
        }
        map.put("paymentsList", paymentsService.getAllPayments());
        return "payments";
    }
}
payments.jsp:


您似乎只有一个处理程序映射,它是POST。使用GET为同一url路径添加另一个处理程序映射。考虑后重定向获取模式。
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%@ include file="/WEB-INF/jsp/includes.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="<c:url value="/resources/css/design.css" />" rel="stylesheet">
<link href="<c:url value="/resources/css/customized.css" />" rel="stylesheet">
<link href="<c:url value="/resources/css/bootstrap.css" />" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Canadian Immigration Consultancy</title>
</head>
<body>
<div id="wrapper">
    <div id="logo">
        <img src="<c:url value="/resources/images/logo4.png" />" height="200px" width="230px"/>
        <img src="<c:url value="/resources/images/header06.jpg" />" height="200px" width="765px"/>
    </div>  

    <div class="red">
        <div align="center" id="slatenav">
            <ul>
                <li><a href="http://localhost:8080/SoftwareProject/home" title="css menus">Home</a></li>
                <li><a href="http://localhost:8080/SoftwareProject/viewAll" title="css menus">View All</a></li>
                <li><a href="#" title="css menus">Reports</a></li>
                <li><a href="http://localhost:8080/SoftwareProject/addleads">Add Leads</a></li>
                <li><a href="<c:url value='j_spring_security_logout'/>"><spring:message code="user.logout"/></a></li>
            </ul>
        </div>
    </div>

    <div id="balance" >
    <form action="addPayments" method="POST">
       <div class="well well-sm box16">
        <div class="panel panel-info">
            <div class="panel-heading">
                <h3 class="panel-title">Payments</h3>
            </div>
            <div class="panel-body">



    <div class="form-group">
       <br><div  class="col-sm-2 control-label">Transaction Name</div>
        <div class="col-sm-10">
          <input type="text" class="form-control" name="transactName"  autofocus />
        </div>
    </div>


      <div class="form-group">
       <br><div class="col-sm-2 control-label">Amount Paid</div>
        <div class="col-sm-10">
          <input type="text" class="form-control" name="paid" />
        </div>
    </div>


      <div class="form-group">
       <br><div class="col-sm-2 control-label">Unpaid</div>
        <div class="col-sm-10">
          <input type="text" class="form-control" name="unpaid" />
        </div>
    </div>


      <div class="form-group">
       <br><div class="col-sm-2 control-label">Total Balance</div>
        <div class="col-sm-10">
          <input type="text" class="form-control" name="balance" />
        </div>
    </div>


      <div class="form-group">
       <br><div class="col-sm-2 control-label">Total Amount</div>
        <div class="col-sm-10">
          <input type="text" class="form-control" name="total" />
        </div>
    </div>




    <div class="save">

                    <input type="submit" class="btn btn-success" value="Save" />


    </div>
        </form>     
            </div>
        </div>




</div>
</body>
</html>