提交按钮在点击时无作用。

huangapple 未分类评论50阅读模式
标题翻译

Submit button does nothing when clicked

问题

<table border="1">
    <tr>
        <td><spring:message code="label.id" /></td>
        <td><spring:message code="label.name" /></td>
        <td><spring:message code="label.abv" /></td>
        <td><spring:message code="label.Buy" /></td>
        <td><spring:message code="label.Sell" /></td>
        <td><spring:message code="label.LastMod" /></td>
        <td><spring:message code="label.Description" /></td>
        <td><spring:message code="label.image" /></td>
        <td><spring:message code="label.catagory" /></td>
        <td><spring:message code="label.style" /></td>
        <td><spring:message code="label.actions" /></td>
    </tr>
    <c:forEach items="${Beers}" var="Beers"> 
        <tr>
            <td>${Beers.id}</td>
            <td>${Beers.name}</td>
            <td>${Beers.abv}</td>
            <td>${Beers.buyPrice}</td>
            <td>${Beers.sellPrice}</td>
            <td>${Beers.lastMod}</td>
            <td>${Beers.description}</td>
            <td><img src="../assets/images/no_image.jpg" alt="<spring:message code="label.image" />"/></td>
            <td>${Beers.catId}</td>
            <td>${Beers.styleId}</td>
            <td>
                <!-- PROBLEM HERE -->
                <form:form method="POST" action="/TasteLimerickBeersB/Beers/UpdateBeerPrice?id=${Beers.id}" modelAttribute="priceIncrease">
                    <label for="priceIncrease"><spring:message code="label.percentage" /></label>
                    <input type="text" name="priceIncrease" maxlength="4" max="100" pattern="[+-?0-9]+([\.][0-9]{0,2})?">
                    <button type="submit" value="Submit!"><spring:message code="submit.button" /></button>
                </form:form>
            </td>
        </tr>
    </c:forEach>
</table>
英文翻译

When the submit button is clicked nothing happens. Only clicks and won't call the controller method. Completely unsure why. I have tried multiple methods of submit. Both external form and inline forms.

&lt;table border=&quot;1&quot;&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;spring:message code=&quot;label.id&quot; /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;spring:message code=&quot;label.name&quot; /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;spring:message code=&quot;label.abv&quot; /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;spring:message code=&quot;label.Buy&quot; /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;spring:message code=&quot;label.Sell&quot; /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;spring:message code=&quot;label.LastMod&quot; /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;spring:message code=&quot;label.Description&quot; /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;spring:message code=&quot;label.image&quot; /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;spring:message code=&quot;label.catagory&quot; /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;spring:message code=&quot;label.style&quot; /&gt;&lt;/td&gt;
            &lt;td&gt;&lt;spring:message code=&quot;label.actions&quot; /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;c:forEach items=&quot;${Beers}&quot; var=&quot;Beers&quot;&gt; 
            &lt;tr&gt;
                &lt;td&gt;${Beers.id}&lt;/td&gt;
                &lt;td&gt;${Beers.name}&lt;/td&gt;
                &lt;td&gt;${Beers.abv}&lt;/td&gt;
                &lt;td&gt;${Beers.buyPrice}&lt;/td&gt;
                &lt;td&gt;${Beers.sellPrice}&lt;/td&gt;
                &lt;td&gt;${Beers.lastMod}&lt;/td&gt;
                &lt;td&gt;${Beers.description}&lt;/td&gt;
                &lt;td&gt;&lt;img src=&quot;../assets/images/no_image.jpg&quot; alt=&quot;&lt;spring:message code=&quot;label.image&quot; /&gt;&quot;/&gt;&lt;/td&gt;
                &lt;td&gt;${Beers.catId}&lt;/td&gt;
                &lt;td&gt;${Beers.styleId}&lt;/td&gt;
                &lt;td&gt;
           //PROBLEM HERE 
            &lt;form:form method=&quot;POST&quot; action=&quot;/TasteLimerickBeersB/Beers/UpdateBeerPrice?id=${Beers.id}&quot; modelAttribute=&quot;priceIncrease&quot;&gt;
                
                &lt;label for=&quot;priceIncrease&quot;&gt;&lt;spring:message code=&quot;label.percentage&quot; /&gt;&lt;/label&gt;
                &lt;input type=&quot;text&quot; name=&quot;priceIncrease&quot; maxlength=&quot;4&quot; max=&quot;100&quot; pattern=&quot;[+-?0-9]+([\.][0-9]{0,2})?&quot;&gt;
                
                &lt;button type=&quot;submit&quot; value=&quot;Submit!&quot;&gt;&lt;spring:message code=&quot;submit.button&quot; /&gt;&lt;/button&gt;
            &lt;/form:form&gt;
            
        &lt;/td&gt;
    &lt;/tr&gt;

&lt;/c:forEach&gt;

</table>

答案1

得分: 0

&lt;%@ taglib prefix=&quot;form&quot; uri=&quot;http://www.springframework.org/tags/form&quot;%&gt; 
这一行对于任何陷入同样陷阱的人来说都是缺失的....
英文翻译

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
this line was missing for anyone who falls into the same trap....

huangapple
  • 本文由 发表于 2020年3月17日 01:43:39
  • 转载请务必保留本文链接:https://java.coder-hub.com/60710744.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定