2

Probably missing something completely obvious here, but here goes. I'm starting out with Spring MVC. I have a form controller to process inbound requests to /share/edit.html. When I hit this url from my browser, I get the following error:

 The requested resource (/inbox/share/share/edit) is not available.

Here is my applicationContext-mvc.xml:

 <bean id="publicUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" >
        <property name="mappings" >
            <value>
                /share/edit.html=shareFormController
                /share/list.html=shareController
                /share/view.html=shareController
                /folders.json=foldersController
                /studies.json=studiesController
            </value>
        </property>
    </bean>


<bean id="internalPathMethodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.InternalPathMethodNameResolver" />

<bean id="shareFormController" class="com.lifeimage.lila.controller.ShareFormController" />
<bean id="shareController" class="com.lifeimage.lila.controller.ShareController" >
    <property name="methodNameResolver" ref="internalPathMethodNameResolver" />
</bean>

and my form Controller:

public class ShareFormController extends SimpleFormController {

    public ShareFormController() {
        setCommandClass( Share.class );
    }

    @Override
    protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors)
            throws Exception {

        //controller impl...

    }



}
1
  • Interestingly enough, changing the URL mapping from /share/edit.html to /edit.html makes the mapping work. But this makes no sense; I wouldn't be able to any other forms here. Commented May 12, 2009 at 16:35

4 Answers 4

1

You should look at your view resolver. Make sure that it is resolving the logical name in your controller as you think it should. Looks like the name it is resolving it to does not exist currently

Sign up to request clarification or add additional context in comments.

Comments

1

I think I've resolved this issue. There were two problems:

1) Implementations of SimpleFormController require a form and success view; which I had not configured here. As this is a server method for an AJAX client, I added a Spring-JSON view as follows:

<?xml version="1.0" encoding="UTF-8"?>

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" default-lazy-init="false" default-autowire="no" default-dependency-check="none">

<bean name="jsonView" class="org.springframework.web.servlet.view.json.JsonView">
        <property name="jsonErrors">
            <list>
                    <ref bean="statusError" />
                    <ref bean="modelflagError" />
            </list>
    </property>
</bean>

<bean name="statusError" 
      class="org.springframework.web.servlet.view.json.error.HttpStatusError">
      <property name="errorCode"><value>311</value></property>
</bean>
<bean name="modelflagError" 
      class="org.springframework.web.servlet.view.json.error.ModelFlagError">
      <property name="name"><value>failure</value></property>
      <property name="value"><value>true</value></property>
</bean>

which can be used for all controllers that return JSON.

2) I switched from a SimpleURLHandlerMapping to ControllerClassNameHandlerMapping and relied on Spring naming conventions ( controllerClassName/method.html ), which fixed the routing issue. Might not be a long term solution, but got me through the task.

Comments

0

Did you check your log output? Spring MVC is generally pretty verbose in what it outputs.

Also, the URL you've posted (/inbox/share/share/edit) does not seem to match what you are configuring (/share/edit.html).

2 Comments

I think that's the problem. /inbox/share/edit.html is the URL I'm trying to get the Controller to listen to. Why would the path name repeat?
Not sure. Could be issue with mapping from URL to controller of issue with resolving a view. Really, check the logs.
0

@jordan002 when I see all the hoops you had to jump to accomplish your task, I feel obliged to share a very powerful Java MVC framework that requires much less configuration. The framework is called Induction, check out the article Induction vs. Spring MVC, http://www.inductionframework.org/induction-vs-spring-mvc.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.