私のコントローラーは現在http://example.com/fix.goのようなものにマップされていますが、もちろん、それはばかげていると思います。http://example.com/fixやhttp://exampleのようなもっと良いものが必要です。拡張子のないcom/mmm/fix 。ただし、これを構成しようとすると、機能しません。マッピング全体を理解する上で重要な部分が明らかに欠けています。コントローラーにSpring3.x、tomcat、およびアノテーションを使用しています。
私のweb.xmlは次のとおりです。
<?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>
そして、私のコントローラーの1つは次のように構成されています。
@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 { ... }
}
http://example.com/mmm/fixのようなURLが機能することを期待して、web.xmlのマッピングを/ mmm / *に変更しようとしましたが、それも機能しませんでした。ブラウザに正しいURLと思われるものを入力すると、「リソース不足」エラーが発生します。
私はここで何を間違えていますか?私にはどのような重要な理解が欠けていますか?作業中の別のプロジェクトで拡張機能なしのものを機能させようとしましたが、そこにも到達できませんでした。私は明らかに何かが欠けています。