相关疑难解决方法(0)

如何在servlet 3.0的web.xml-less中定义<welcome-file-list>和<error-page>?

我有现有的web-app,我想将其转换为web.xml-less servlet 3.0.我已经设法使它工作,但是web.xml中有2个标签,我仍然不知道web.xml-less环境中的等效代码.

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

<error-page>
    <error-code>404</error-code>
    <location>/pageNotFound</location>
</error-page>
Run Code Online (Sandbox Code Playgroud)

任何帮助表示赞赏

java servlet-3.0 java-ee-6 tomcat7

28
推荐指数
2
解决办法
2万
查看次数

在使用基于纯Java的配置而不是web.xml开发spring mvc应用程序时如何设置welcome-file?

我正在使用Spring MVC开发一个Web应用程序,它基于纯Java,没有web.xml配置.我编写了下面的类来加载bean并设置url模式.如何设置welcome-file?

public class MyAppWebAppIntializer implements WebApplicationInitializer {
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        AnnotationConfigWebApplicationContext appCtx = new AnnotationConfigWebApplicationContext();
        appCtx.register(ApplicationContextConfig.class);

        Dynamic dispatcher = servletContext.addServlet(
                "SpringDispatcher", new DispatcherServlet(appCtx));
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping("/");
    }
}
Run Code Online (Sandbox Code Playgroud)

configuration spring spring-mvc welcome-file

2
推荐指数
1
解决办法
3014
查看次数