Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 6th, 2008, 11:18 PM   #1
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,649
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
Spring Framework Controller

I have been playing around with java web programming a lot lately, and am using the Spring Framework MVC to do this. My problem is that when I go to the url http://localhost:8080/Forum/index.html the spring framework calls the controller it is suppose to call, but when I go to http://localhost:8080/Forum/ it won't call the controller, and I can't seem to figure out how I can get it to do that.

Below is my web.xml file:
xml Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  3. <display-name>Forum</display-name>
  4.  
  5. <servlet>
  6. <servlet-name>springapp</servlet-name>
  7. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  8. <load-on-startup>1</load-on-startup>
  9. </servlet>
  10.  
  11. <servlet-mapping>
  12. <servlet-name>springapp</servlet-name>
  13. <url-pattern>*.html</url-pattern>
  14. </servlet-mapping>
  15.  
  16. <welcome-file-list>
  17. <welcome-file>index.jsp</welcome-file>
  18. </welcome-file-list>
  19.  
  20. </web-app>

Below is my springapp-servlet.xml
xml Syntax (Toggle Plain Text)
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
  3.  
  4. <!--
  5.   - Application context definition for "springapp" DispatcherServlet.
  6.   -->
  7.  
  8. <beans>
  9. <!-- TILES CONFIG -->
  10. <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
  11. <property name="definitions">
  12. <list>
  13. <value>/WEB-INF/tiles-defs.xml</value>
  14. </list>
  15. </property>
  16. </bean>
  17.  
  18. <bean id="defaultController" class="com.kydovik.forum.controller.BaseController" />
  19. <bean id="forumController" class="com.kydovik.forum.controller.ForumController" />
  20. <bean id="threadController" class="com.kydovik.forum.controller.ThreadController" />
  21.  
  22. <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
  23. <property name="mappings">
  24. <value>
  25. /index.html=defaultController
  26. /**/ShowForum.html=forumController
  27. /**/ShowThread.html=threadController
  28. </value>
  29. </property>
  30. </bean>
  31.  
  32. <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  33. <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
  34. <property name="prefix">
  35. <value>/</value>
  36. </property>
  37. <property name="suffix">
  38. <value>.jsp</value>
  39. </property>
  40. </bean>
  41. </beans>
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Old Feb 7th, 2008, 2:11 PM   #2
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 3 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
Re: Spring Framework Controller

EDIT: Nevermind. Sorry.

Maybe you need to play with the mapping options more. All I can think of.
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Old Feb 11th, 2008, 7:05 AM   #3
pushkarajthorat
Java Developer
 
pushkarajthorat's Avatar
 
Join Date: Jun 2006
Location: Solapur, India.
Posts: 24
Rep Power: 0 pushkarajthorat is an unknown quantity at this point
Send a message via Yahoo to pushkarajthorat
Re: Spring Framework Controller

when you call any URL; procedure to locate this resource within the webserver is:

for a URL:
<http|https>://<hostname|IP>[:portno]/<ApplicationName>/[Resource]
1: Go to the <ApplicationName>'s web.xml
2: Find the matching servlet-mapping tag with <url-pattern> regex. for URL:/[Resource] Go to the servelet-mapping tag.. and execute the servelet-class tag servelet
3: If there is no Servelet-mapping match then resource not found error is displayed.
4: if URL:/[Resource] is blank it will take each <welcome-file> from <welcome-file-list> is taken and used as URL:/[Resource] and execute the whole thing from 2: skipping the 3rd point.

In your second case http://localhost:8080/Forum/ resource is blank and specified welcome-file "index.jsp" is not matching with any servelet-mapping tag's <url-pattern> so... Insted of <url-pattern>*.html</url-pattern> put <url-pattern>*.*</url-pattern> in servelet-mapping tag.. so scope of index.jsp will within the front controller.
__________________
[Pushkaraj]


Imagination is more important than knowledge – Albert Einstein
pushkarajthorat is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Symfony Vs Zend Framework Sanjay Aggarwal PHP 5 Aug 12th, 2008 9:58 AM
Model View Controller ( Front Controller ) hoffmandirt Other Web Development Languages 0 Feb 27th, 2006 5:41 PM
VB O5 Program Running Problem..Think its .net framework Silent Visual Basic .NET 3 Dec 15th, 2005 4:43 AM
Framework 2.0 came out, kinda bja888 Coder's Corner Lounge 11 Nov 9th, 2005 4:06 PM
Net Group /ADD (on a windows box, non domain controller) Infinite Recursion Other Programming Languages 1 Apr 13th, 2005 2:27 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:14 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC