English 中文(简体)
我怎么会把春天控制器召集起来,不要延期?
原标题:How do I configure spring controller URLs to not have an extension?

我的控制者目前被描绘成像。 当然,我认为, s和想要像,无延伸。 然而,当我试图混淆这一点时,我就不得不这样做。 我显然没有了解整个绘图工作的一个关键部分。 I m 采用3.x, tomcat,为控制者提供说明。

My web.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<web-app
    version="2.4"
    xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <servlet>
        <servlet-name>BooBoo</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>BooBoo</servlet-name>
        <url-pattern>*.*</url-pattern>   <!-- was *.go when it worked -->
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

</web-app>

BooBoo-servlet.xml:

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

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
        http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:component-scan base-package="com.foofoo.booboo"/>

    <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>

我的一位控制员配置如下:

@Controller
public class BangBangController extends BaseController {

            // Used to be fix.go when it worked
    @RequestMapping( value="fix", method=RequestMethod.GET )
    public ModelAndView choose(
            HttpSession session,
            @RequestParam( value="fixId", required=false, defaultValue="-1" ) Integer fixId,
            @RequestParam( value="forkId", required=false, defaultValue="-1" ) Integer forkId 
    )
    throws Exception { ... }
}

I ve试图将网上地图转换为/mmm/* ,预期URLs,如,但这项工作也未能奏效。 我在进入我认为是浏览器中正确的URLs时,会发现“放任资源”错误。

我在此谈什么? 我缺乏哪些关键谅解? 我试图使另一个工程项目的延期不会奏效,也不能让它去。 我显然没有东西。

最佳回答

问题在于您的发送服务器正在与“......”相匹配。

改动

 <url-pattern>/*</url-pattern> 

然而,当你赢得时,这同样是坏的。

你应该做的是:

 <url-pattern>/webapp/*</url-pattern> 

如果“网络使用”是某些先决条件。 你们所有的URLs都需要事先加以确定,但允许你继续固定内容。

问题回答

回答是,我没有具体说明我正在使用春天花板。 我赞赏克里斯帮助诊断这一问题。 我需要确认,我所尝试的一些事情(但由于这一错误而失败)是正确的。

增 编

xmlns:mvc="http://www.springframework.org/schema/mvc"

以及

<mvc:annotation-driven />

to that file, 以及boom, it started working. What leaves me scratching my head is, "How did it work without that?" Cuz it worked for *.go patterns.

本文全文见:

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

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="
        http://www.springframework.org/schema/mvc
            http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
        http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:component-scan base-package="com.barbar.foofoo"/>

    <!-- Enables the Spring MVC @Controller programming model -->
    <mvc:annotation-driven />

    <!--
    Declare View Resolver: when view  view_name  is called (from the Controller), 
    the file  /jsp/view_name.jsp  will be used.
    -->
    <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>




相关问题
array dependency injection in spring?

is there a way to use dependency injection to inject all available implementations of a specific interface in spring? This is kind of the same thing as asked here for .NET. Though my aim is to use @...

Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Grails Packaging and Naming Conventions

Packaging Controllers, Services,etc. i.e. - com.company.controllers - com.company.services Is this a good practice or should be avoided by all means?? Another worth mentioning problem I encountered ...

How can I determine Objects in application context?

I am trying to write a portlet for Liferay (using Tomcat and Spring) and need to use a database via Persistence API/Hibernate. I am using some configuration XMLs (applicationContext.xml, etc.) and ...

How to prevent JPA from rolling back transaction?

Methods invoked: 1. Struts Action 2. Service class method (annotated by @Transactional) 3. Xfire webservice call Everything including struts (DelegatingActionProxy) and transactions is configured ...

热门标签