Announcement Announcement Module
Collapse
No announcement yet.
about MVC-step-by-step 2 ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • about MVC-step-by-step 2 ?

    MVC-step-by-step 2
    include.jsp
    Code:
    <%@ page session="false"%>
    <%@ taglib prefix="c" uri="http&#58;//java.sun.com/jstl/core_rt" %>
    <%@ taglib prefix="fmt" uri="http&#58;//java.sun.com/jstl/fmt" %>
    hello.jsp
    Code:
    <%@ include file="/WEB-INF/jsp/include.jsp" %>
    <html><head><title>Hello &#58;&#58; Spring Application</title>
    </head>
    <body>
    <h1>Hello - Spring Application</h1>
    <p>Greetings, it is now <c&#58;out value="$&#123;now&#125;"/>
    </p></body></html>
    return the page when running
    Code:
    Hello - Spring Application
    Greetings, it is now $&#123;now&#125;
    why? ${now} is supposed to time!

  • #2
    why? ${now} is supposed to time!
    It should show the time because of the code below.
    Code:
    String now = &#40;new java.util.Date&#40;&#41;&#41;.toString&#40;&#41;; 
    logger.info&#40;"returning hello view with " + now&#41;;
    return new ModelAndView&#40;"WEB-INF/jsp/hello.jsp", "now", now&#41;;
    Make sure you view the JSP via the controller.

    Comment


    • #3
      My class

      Code:
      import org.springframework.web.servlet.mvc.Controller;
      import org.springframework.web.servlet.ModelAndView;
      
      import javax.servlet.ServletException;
      import javax.servlet.http.HttpServletRequest;
      import javax.servlet.http.HttpServletResponse;
      
      import java.io.IOException;
      
      import org.apache.commons.logging.Log;
      import org.apache.commons.logging.LogFactory;
      
      public class SpringappController implements Controller &#123;
      
          /** Logger for this class and subclasses */
          protected final Log logger = LogFactory.getLog&#40;getClass&#40;&#41;&#41;;
      
          public ModelAndView handleRequest&#40;HttpServletRequest request, HttpServletResponse response&#41;
                  throws ServletException, IOException &#123;
      
              String now = &#40;new java.util.Date&#40;&#41;&#41;.toString&#40;&#41;; 
      
              logger.info&#40;"returning hello view with " + now&#41;;
      
              return new ModelAndView&#40;"WEB-INF/jsp/hello.jsp", "now", now&#41;;
      
          &#125;
      &#125;

      Comment


      • #4
        My view,why?
        http://61.243.187.37/spring.jpg

        Comment


        • #5
          My view,why?
          This looks like a JSTL problem. Can you try:
          Code:
          <%@ taglib prefix="c" uri="http&#58;//java.sun.com/jstl/core" %>

          Comment


          • #6
            I had this problem and it drove me mad but I did find the solution.

            See:
            http://forum.java.sun.com/thread.jsp...hreadID=526444

            Basically, download the latest JSTL 1.1 from Apache:
            http://jakarta.apache.org/taglibs/do...doc/intro.html

            Also, need to change:
            <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
            <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>

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

            Hope this solves it. 8)

            Comment


            • #7
              Spring JSTL

              Like they said you need JSTL 1.1 and the last time i checked Spring doesn't ship the jstl 1.1 jar. Jurgen gave the rationale for doing so here http://article.gmane.org/gmane.comp....477/match=jstl

              Comment


              • #8
                Hmmm,
                Bit strange as the "Developing a Spring Framework MVC application step-by-step" doesn't seem to work in the area indicated without it - which is real bad for credibility with newbie users finding their way.

                Comment


                • #9
                  include jar files

                  Do you have the latest copy the jstl.jar and standard.jar files? For easy access, I downloaded the distribution with dependencies so I don't have to keep going to the websites for the jars.

                  sami

                  Comment

                  Working...
                  X