0
MVC-调度-servlet.xml中:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="com.javaguru.game"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
<mvc:resources mapping="/resources/**" location="/resources/" />
控制器:
@Controller
public class MainController {
@RequestMapping(value = {"/", "/home"}, method = RequestMethod.GET)
public String printWelcome(ModelMap model) {
model.addAttribute("message", "Hello world!");
return "hello";
}
}
加入MVC后:资源标记我进入我的资产(这里是一切正常,因为它应该是):
问题出在哪里?
在此先感谢。
是的,我已经试过了。游戏/主页正在工作,但如果我尝试游戏/(我的索引页面)它说:模糊处理程序方法映射为HTTP路径'http:// localhost:8080/game /':{public java.lang.String com.javaguru .game.HelloController.printWelcome(org.springframework.ui.ModelMap),public java.lang.String com.javaguru.game.MainController.printWelcome(org.springframework.ui.ModelMap)} – Aleksandrs
但是,当我看到你的异常,我看到有两个不同的控制器,你好,主控制器。在HelloContoller中是否有任何方法指向/ game /的路径?这会导致模糊。 –
我更新了结构图。我只有一个控制器。 – Aleksandrs