获取单选按钮的值为$ {param}

时间:2015-02-19 04:41:05

标签: html jsp radio-button param

基本上我这里有两个radiobuttons,具有不同的值,现在提交时,下一页应显示选择。但它没有,当我尝试使用type = text时它工作正常。请帮忙。

<form action="Confirm.jsp">
  <p>
    This is a simple HTML page that has a form in it.
    <br>form data is: <strong>${param.QuizAnswer}</strong>
    <p>
      Hobby:
      <input type="radio" name="QuizAnswer" value="cats">Cats


      <input type="radio" name="QuizAnswer" value="dogs">Dogs


      <input type="submit" name="submit" value="submit">
</form>

其他页面在身体中有这个:

<body>
  <p>
    This is barebones, sorry.

    <p>The Data was entered as:
      <strong>${param.QuizAnswer}</strong>
</body>

2 个答案:

答案 0 :(得分:0)

Plz按以下方式更改接收页面

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
      <c:choose>
     <c:when test="${empty param.QuizAnswer}">
        Please enter your name.
    </c:when>
    <c:otherwise>
        Hello <b><c:out value="${param.QuizAnswer}" /></b>!
    </c:otherwise>
</c:choose>
    </body>
</html>

请检查并告诉我

答案 1 :(得分:-1)

通过将表单发送到Confirm.jsp,您可以将表单数据作为实际表单提交发送到后端。如果这是您想要的,您应该在后端处理表单参数。

如果您想要使用表单提交来更改前端的内容,您应该将表单发送到空目的地(表单操作=&#34;&#34;)并处理提交在javascript事件处理程序中。这是一个例子:

Print value on form submit

相关问题