我想知道为什么我在这里收到404错误,但我看不到它。
这是我的web.xml:
<servlet>
<servlet-name>ep</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ep</servlet-name>
<url-pattern>/ep/*</url-pattern>
</servlet-mapping>
这是我的ep-servlet.xml(以下代码只包含“beans”标签):
<mvc:annotation-driven />
<context:component-scan base-package="server.service2">
</context:component-scan>
这是班级本身:
package server.service2;
....
@Controller
@RequestMapping("/user")
public class LoginService
{
@RequestMapping(value = "/check/{username}", method = RequestMethod.GET)
public void checkUsername(@PathVariable("username") String username)
{
}
}
我正在使用浏览器访问的网址是:
http://<server>:<correct-port>/ep/user/check/username
它回来了404!谁能发现我在这里做错了什么?
答案 0 :(得分:0)
您好@Amorgos您可以将文件订购到下一个:
的web.xml
<servlet>
<servlet-name>ep</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ep</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- Add Support for Spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>
EP-servlet.xml中
<context:annotation-config />
<context:component-scan base-package="server.service2" />
<beans:bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" />
<!-- Register the bean -->
<beans:bean class="server.service2.LoginService" />
我希望这些有用:)