开发者

JSP page not reading submitted for values

开发者 https://www.devze.com 2022-12-17 12:21 出处:网络
I am working on the front end of a jsp based app. We\'re using spring running on weblogic. I have a page with a form that submits to itself and I am trying to access the values of hidden fields that

I am working on the front end of a jsp based app. We're using spring running on weblogic.

I have a page with a form that submits to itself and I am trying to access the values of hidden fields that I set with javascript.

 <form method="post">

  <input type="hidden" name="choosenDateFrom" value="test1" />
  <input type="hidden" name="choosenDateTo" value="test2"  />
.... more code

However when I use th开发者_StackOverflow中文版e code on the same page:

 <c:choose>
  <c:when test="${param.choosenDateFrom!=null}">
   <c:out value="${param.choosenDateFrom}" />
 </c:when>
   </c:choose>

The params are not shown on the page. What am I missing? I though this is the standard way of doing this.

Could it be that since we are using a MVC framework I can't pass params around like this?


Do you have JSTL installed in webapp and declared in JSP?

Check the generated HTML output (open page in browser, choose View Source). It should contain no traces of any JSTL code. If it does, then you likely just need to install JSTL first. Just drop jstl-1.2.jar in webapp's /WEB-INF/lib and declare the taglib in top of JSP as per the JSTL core TLD:

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

If that still doesn't solve the problem, then there's apparently means of a brand new request (i.e. a redirect has occurred), or you were using wrong parameter names. Use <c:out value="${pageContext.request.parameterMap}" /> to see all names.

As per your doubt:

Could it be that since we are using a MVC framework I can't pass params around like this?

That purely depends on which one you're using. Not mentioning it doesn't help us to give better answers. But in general the ${param} should be left untouched.


have you included the core lib in your jsp? Most of the the cases that what happens and jsp just ignores your syntax.

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


You may want to use Firefox plugin named Tamper Data to see if your parameters are actually being posted correctly. Verify that you are not doing a redirect after post because you would loose all your parameters since it asks the browser to perform a new request.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号