图片上传不过来,就复制了。。。
感谢各位大佬过来给建议,我看我的配置应该没问题,555
访问mvc的controller方法时,页面直接报404(找不到 localhost 的网页找不到与以下网址对应的网页:http://localhost:8080/regist HTTP ERROR 404) 没进去controller里面。我的相关配置如下:html文件夹在
webapp下的WEB-INF里,工具idea
web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/springApplocation.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>dispatchServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/springApplocation-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatchServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
mvc的配置文件
<!--注解驱动-->
<mvc:annotation-driven/>
<!--包扫描-->
<context:component-scan base-package="cn.sty.test.controller"/>
<!--视图解析器-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/html"/>
<property name="suffix" value=".html"/>
</bean>
controller
@Controller
public class UserServlet {
@RequestMapping(value = "/regist", method = RequestMethod.GET)
public String regist(){
System.out.println("我进来了");
return "index";
}
}
```![图片说明](https://img-ask.csdn.net/upload/201904/21/1555839445_485612.jpg)