We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Maven generated Spring Framework not working

Medium Priority
421 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.
Comment
Watch Question

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
what path are you requesting?

Author

Commented:
>> ...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.
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
only the login page is mapped to be handled by spring in your webapp
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
if you look in the spring config

        
              
                    springDemoController
              
        

there is only one mapping

Author

Commented:
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?
Java Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
>                     softRetailController

try:

                    softRetailController


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


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
That was it.

Thanks!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.