Announcement Announcement Module
Collapse
No announcement yet.
Spring mcv generate mapping error... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring mcv generate mapping error...

    Hello there, today i search for the resource bundling, and i did it, i also face lot of other thing tried to put them here, i get lot of errors, remove all, and after all, i reached to my begin step, only i have resurce bundling context in my bean file, but server generate error:

    -page-error-
    Code:
    HTTP Status 404 -
    
    type Status report
    
    message
    
    description The requested resource () is not available.
    -server-error-
    Code:
    WARN  27-02 16:47:44,024 - No mapping found for HTTP request with URI [/student_proceeds_report.html] in DispatcherServlet with name 'springmvc'
    my configuration:

    -spring-mvc
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans ...>
    
        <import resource="hibernateContext.xml"/>
        <import resource="pagesContext.xml"/>
    
        <!-- Resource Bundling -->
        <bean id="messageSource"
              class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basename" value="classpath:messages" />
            <property name="defaultEncoding" value="UTF-8"/>
        </bean>
    
        <bean id="localeChangeInterceptor"
              class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
            <property name="paramName" value="lang" />
        </bean>
    
        <bean id="localeResolver"
              class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
            <property name="defaultLocale" value="fa"/>
        </bean>
    
        <bean id="handlerMapping"
              class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
            <property name="interceptors">
                <ref bean="localeChangeInterceptor" />
            </property>
        </bean>
    
        <!-- Configure view resolver -->
        <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
            <property name="prefix" value="/jsp/"/>
            <property name="suffix" value=".jsp"/>
        </bean>
    </beans>
    -pageContext
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans...>
    
        <bean name="/student_proceeds_report.html" class="com.bedkaco.web.StudentProceedsReport">
        </bean>
    </beans>
    -web.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" ...>
    
        <servlet>
            <servlet-name>springmvc</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
    
    
        <servlet-mapping>
            <servlet-name>springmvc</servlet-name>
            <url-pattern>*.html</url-pattern>
        </servlet-mapping>
    
    </web-app>
    -student_proceeds_report.jsp
    Code:
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="f" uri="http://www.springframework.org/tags/form" %>
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
    
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>
                <spring:message code="titles.main_title"/>
            </title>
            <link href="/css/layout.css" type="text/css" rel="stylesheet"/>
        </head>
        <body dir="<spring:message code="page.direction"/>">
            <f:form method="post">
                <table border="1" cellpadding="2" cellspacing="2" align="center">
                    <tr>
                        <td height="30" colspan="2">
                            <!-- Header -->
                            <h3>
                                <spring:message code="header.language"/>
                            </h3>
                            <span style="float: right">
                                <a href="?lang=en">en</a>
                                |
                                <a href="?lang=de">de</a>
                            </span>
                        </td>
                    </tr>
                    <tr>
                        <td width="350" valign="top">
                            <div class="search_table">
                                <table>
                                    <tr>
                                        <td>
                                            <spring:message code="std_prc_rpt.student_number"/>
                                            <f:input path="stno" tabindex="0"/>
                                        </td>
                                        <td>
                                            <spring:message code="std_prc_rpt.year"/>
                                            <f:input path="year" tabindex="1"/>
                                        </td>
                                        <td>
                                            <spring:message code="std_prc_rpt.semester"/>
                                            <f:input path="semester" tabindex="2"/>
                                        </td>
                                        <td>
                                            <input type="submit" value="<spring:message code="std_prc_rpt.search"/>" name="search" tabindex="3" accesskey="s"/>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                    </tr>
            </f:form>
        </body>
    </html>
    -Controller class
    Code:
    package com.bedkaco.web;
    
    import com.bedkaco.portlets.group.factories.GroupFactory;
    import com.bedkaco.portlets.major.factories.MajorFactory;
    import com.bedkaco.portlets.major.model.Major;
    import com.bedkaco.portlets.student.factories.StudentFactory;
    import com.bedkaco.portlets.student.model.Student;
    import com.bedkaco.portlets.user_account.factories.UserAccountFactory;
    import com.bedkaco.portlets.user_account.model.UserAccount;
    import org.springframework.web.bind.ServletRequestDataBinder;
    import org.springframework.web.servlet.ModelAndView;
    import org.springframework.web.servlet.mvc.SimpleFormController;
    import org.springframework.web.servlet.support.RequestContext;
    import org.springframework.web.servlet.view.RedirectView;
    
    import javax.servlet.http.HttpServletRequest;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.ResourceBundle;
    
    public class StudentProceedsReport extends SimpleFormController{
    
        @Override
        protected Object formBackingObject(HttpServletRequest request) throws Exception {
            Student defaultStudent = new Student();
            return defaultStudent;
        }
    
        @Override
        protected Map referenceData(HttpServletRequest request) throws Exception {
            Map<Object, Object> dataMap = new HashMap<Object, Object>();
            return dataMap;
        }
    
        @Override
        protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
            super.initBinder(request, binder);
        }
    
        @Override
        protected ModelAndView onSubmit(Object command) throws Exception {
            ModelAndView modelAndView = new ModelAndView("student_proceeds_report");
    
    
            return modelAndView;
        }
    }

  • #2
    i find out that the error, happen exactly in here, and cause system to not reading my springmvc-servlet files:

    Code:
        <!-- Resource Bundling -->
        <bean id="messageSource"
              class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basename" value="classpath:messages" />
            <property name="defaultEncoding" value="UTF-8"/>
        </bean>
    
        <bean id="localeChangeInterceptor"
              class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
            <property name="paramName" value="lang" />
        </bean>
    
        <bean id="localeResolver"
              class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
            <property name="defaultLocale" value="fa"/>
        </bean>
    
        <bean id="handlerMapping"
              class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
            <property name="interceptors">
                <ref bean="localeChangeInterceptor" />
            </property>
        </bean>
    now the problem is, what should i replace it?

    Comment


    • #3
      if you are saying that its not reading from Springmvc.xml can you show what exact name of that file? here you mapped with "spring-mvc" where as in web.xml its like "springmvc". if your web.xml is correct plz make it as "springmvc-servlet"

      Comment


      • #4
        if, you read my previous post, it happen when i add these codes:
        to spring context... which is springmvc-servlet.xml in my project
        Code:
            <!-- Resource Bundling -->
            <bean id="messageSource"
                  class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
                <property name="basename" value="classpath:messages" />
                <property name="defaultEncoding" value="UTF-8"/>
            </bean>
        
            <bean id="localeChangeInterceptor"
                  class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
                <property name="paramName" value="lang" />
            </bean>
        
            <bean id="localeResolver"
                  class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
                <property name="defaultLocale" value="fa"/>
            </bean>
        
            <bean id="handlerMapping"
                  class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
                <property name="interceptors">
                    <ref bean="localeChangeInterceptor" />
                </property>
            </bean>
        but if i remove it, then my application cant read the properties file, ...

        Comment


        • #5
          i remove these :
          [/CODE]
          <!--
          <bean id="localeChangeInterceptor"
          class="org.springframework.web.servlet.i18n.Locale ChangeInterceptor">
          <property name="paramName" value="lang"/>
          </bean>

          <bean id="handlerMapping"
          class="org.springframework.web.servlet.mvc.annotat ion.DefaultAnnotationHandlerMapping">
          <property name="interceptors">
          <ref bean="localeChangeInterceptor"/>
          </property>
          </bean>
          -->[CODE]

          my page come up...
          what should i do to fix it? i want to let user choose language :|

          Comment

          Working...
          X