请求的资源不可用html,Spring MVC请求的资源不可用

时间:2025-03-09 08:55:43

我有一个带有公共函数索引()的单个控制器类()的战争项目,该函数返回一个字符串,该字符串是我最后一次检查视图的名称正在转发 - 和一个名为“”的jsp。这些视图位于/ main/webapp/WEB-INF/views/jsp /中。 :Spring MVC请求的资源不可用

@Controller

public class MainController

{

@Autowired

private ApplicationContextProvider mObjApplicationContextProvider;

@Autowired

private ScheduleService mObjScheduleService;

protected ApplicationContext getApplicationContext()

{

return(getApplicationContextProvider().getApplicationContext());

}

protected ApplicationContextProvider getApplicationContextProvider()

{

return(mObjApplicationContextProvider);

}

protected Object getBean(final Class> clsBean)

{

return(getApplicationContext().getBean(clsBean));

}

protected Object getBean(final String sBeanName)

{

return(getApplicationContext().getBean(sBeanName));

}

protected ScheduleService getScheduleService()

{

return(mObjScheduleService);

}

@RequestMapping(value="/")

public String index()

{

return("index");

}

}

的:

Insert title here

Hello World!

我的XML配置文件:

xmlns:context="/schema/context"

xmlns:xsi="http:///2001/XMLSchema-instance"

xmlns:mvc="/schema/mvc"

xsi:schemaLocation="/schema/beans /schema/beans/

/schema/mvc /schema/mvc/spring-mvc-4.

/schema/context /schema/context/spring-context-4.">

出于某种原因,我得到了我的浏览器中的错误,当我去“http://localhost:8080/Ushering/ “:404 - ”请求的资源不可用。“

我在日志中找不到任何东西(但可以发布,如有必要)告诉我什么文件或资源无法使用。它似乎能够找到控制器,因为它在一个日志文件中提到了控制器的请求映射。会是什么呢?

编辑:WAR文件按照在pom文件中定义的方式启动,也在中作为项目的名称,所以我会认为上下文将是启动以及任何在Spring应用程序端的事情会在/引发之后,所以如果我将请求映射设置为/ Hello,那么URL应该是localhost:8080/Ushering/Hello。

编辑:我的文件

CrunchifySpringMVCTutorial

Ushering

contextConfigLocation

/WEB-INF/

1

Ushering

/s

+0

你能发布你的文件吗? –

+0

将其添加为编辑 –

+0

我明白了!当我将 -/s贴在底部附近的url-pattern中时,我注意到了一个错字。它应该是/且只有/。我删除了's',干净的编译战争:战争编辑它,它出现了,因为我期待:-D谢谢你在正确的方向戳我! –