Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Maven generated Spring Framework not working

Posted on 2009-02-18
7
Medium Priority
?
402 Views
Last Modified: 2013-11-11
I have a maven generated spring framework webapp that deploys and navigates screen to screen, but doesn't appear to be passing through the Java Controller Application. EE won't allow me to upload the ZIP file because it contains an XML file, but if anyone will contact me via email at doug.thomas@softechnics.com, I will send them the ZIP file.

I don't believe the Controller is being excercised because it is suppose to write to stdout and to the logger and it's suppose to return a parameter to be displayed on my JSP page. None of these seem to be happening.
0
Comment
Question by:softechnics
  • 4
  • 3
7 Comments
 
LVL 92

Expert Comment

by:objects
ID: 23687029
what path are you requesting?

0
 

Author Comment

by:softechnics
ID: 23692452
>> ...what path are you requesting?

Pardon my ignorance, but what are you asking?

URL: http://localhost:8080/softretail
web.xml: <url-pattern>/softretail/*</url-pattern> (modified from /softretail/jsp/*)

Did you get the app to work for you?

BTW, I did get JUnit to finally work (mispelled the Test class and had to add the Surefire plug-in.). Now, I just need to get the Controller to respond with my data for my JSP.
0
 
LVL 92

Expert Comment

by:objects
ID: 23696048
only the login page is mapped to be handled by spring in your webapp
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 92

Expert Comment

by:objects
ID: 23696517
if you look in the spring config

        
              
                    springDemoController
              
        

there is only one mapping

0
 

Author Comment

by:softechnics
ID: 23716092
I was trying to just get one page submitted to the Controller (logon.jsp) and another sent back to the client in return (mainMenu.jsp). Didn't think I had to map maniMenu.jsp, since I wasn't concerned with what happened after that. However, I have now added to/changed:

web.xml:

  <servlet>
    <servlet-name>softRetail</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>softRetail</servlet-name>
    <url-pattern>/softretail/jsp/*</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

softRetail-servlet.xml:

  <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="mappings">
              <props>
                    <prop key="**">softRetailController</prop>
              </props>
        </property>
      <property name="alwaysUseFullPath">
            <value>true</value>
      </property>
  </bean>

  <bean id="softRetailController" class="com.softechnics.softretail.spring.SoftRetailController"/>

  <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
      <property name="prefix">
      <value>/jsp/</value>
      </property>
      <property name="suffix">
      <value>.jsp</value>
      </property>
  </bean>

applicationContext.xml:

<beans>
  <bean id="logon" class="com.softechnics.softretail.spring.SoftRetailController">
    <property name="testString" value="This is a test string from SoftRetailController::logon()" />
  </bean>
  <bean id="mainMenu" class="com.softechnics.softretail.spring.SoftRetailController">
    <property name="testString" value="This is a test string from SoftRetailController::mainMenu()" />
  </bean>
</beans>

SoftRetailController.java:

public class SoftRetailController extends MultiActionController
{
         public String testString;
         
    protected final Log logger = LogFactory.getLog(getClass());

    public ModelAndView logon(HttpServletRequest request, HttpServletResponse response)
        throws Exception
    {
          testString = "test from logon()";
        logger.info("INFO:SoftRetailController::logon - Returning=> " + testString);
       
        if (request != null) {
              System.out.println("INFO:SoftRetailController::logon received\n" +
                    "Attributes=>" + request.getAttributeNames() +
                    "Parameters=>" + request.getParameterNames());
        }
        System.out.println("INFO:SoftRetailController::logon - Returning=> " + testString);
       
        ModelAndView mav = new ModelAndView("mainMenu");
        mav.addObject("testString",testString);

        return mav;
    }
   
    public ModelAndView mainMenu(HttpServletRequest request, HttpServletResponse response)
        throws Exception
    {
          testString = "test from mainMenu()";
        logger.info("INFO:SoftRetailController::mainMenu - Returning=> " + testString);

        if (request != null) {
              System.out.println("INFO:SoftRetailController::mainmenu received\n" +
                    "Attributes=>" + request.getAttributeNames() +
                    "Parameters=>" + request.getParameterNames());
        }
        System.out.println("INFO:SoftRetailController::mainMenu - Returning=> " + testString);
       
        ModelAndView mav = new ModelAndView("logon");
        mav.addObject("testString",testString);

        return mav;
    }
}

It appears my logon.jsp page is going directly to mainmenu.jsp without passing through the softRetail Spring servlet. I think this is the case because the println() methods in the Controller are not putting anything to the stdout_xxxx.log.

Comments?
0
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 23717486
>                     softRetailController

try:

                    softRetailController


what urls are you requestiong with?
needs to match   /softretail/jsp/* as that is all that is getting handled by spring


0
 

Author Comment

by:softechnics
ID: 23721735
That was it.

Thanks!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
A solution for Fortify Path Manipulation.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question