我正在尝试处理Spring调度程序servlet中的请求。获取未找到具有URI的HTTP请求的映射
我的web.xml文件中具有的servlet:
<servlet>
<servlet-name>ApplicationDispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/SpringConfig/WebApplication.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ApplicationDispatcher</servlet-name>
<url-pattern>*.json</url-pattern>
<url-pattern>*.do</url-pattern>
<url-pattern>/entities/*</url-pattern>
</servlet-mapping>
我的控制器看起来:
@Controller(value="entities")
public class EntitiesController {
private static final Logger LOGGER = Logger.getLogger(EntitiesController.class);
@Autowired
private IEntityDataService iEntityDataService;
@RequestMapping("/list")
public String displayAllEntities() {
LOGGER.info("Displaying entity dashboard");
return "entity_landing";
}
@RequestMapping("/display")
public String displayCheckpointDashboard(Integer id) {
LOGGER.info("Displaying checkpoint dashboard for id " + id);
return "entity";
}
@RequestMapping("/update")
public String displayUpdateEntity(Integer id) {
System.out.println("Update id " + id);
return "new_entity";
}
@RequestMapping("/add")
public String displayNewEntity() {
LOGGER.info("Displaying new entity page");
return "new_entity";
}
}
我看到以下日志在我的应用程序日志:
2016-01-13 16:15:12 INFO RequestMappingHandlerMapping:180 - Mapped "{[/entity/add/entityDetails.do],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.test.EntityController.saveEntityDetails(com.test.vo.EntityCheckpointsVo)
2016-01-13 16:15:12 INFO RequestMappingHandlerMapping:180 - Mapped "{[/entities/list],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.test.EntitiesController.displayAllEntities()
2016-01-13 16:15:12 INFO RequestMappingHandlerMapping:180 - Mapped "{[/entities/add],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.test.EntitiesController.displayNewEntity()
2016-01-13 16:15:12 INFO DispatcherServlet:476 - FrameworkServlet 'ApplicationDispatcher': initialization completed in 950 ms
2016-01-13 16:15:12 WARN PageNotFound:1116 - No mapping found for HTTP request with URI [/TestProject/entities/add] in DispatcherServlet with name 'ApplicationDispatcher'
2016-01-13 16:15:17 WARN PageNotFound:1116 - No mapping found for HTTP request with URI [/TestProject/entities/add] in DispatcherServlet with name 'ApplicationDispatcher'
2016-01-13 16:17:04 WARN PageNotFound:1116 - No mapping found for HTTP request with URI [/TestProject/entities/add] in DispatcherServlet with name 'ApplicationDispatcher'
我我没有任何线索,因为日志说有/entities/add
已注册。我能够访问其他URL,如localhost:8080/TestProject/entity/add/entityDetails.do,但我无法访问localhost:8080/TestProject/entities/add。
请帮我看看这里。
感谢
更新:
段从EntityController
@Controller
@RequestMapping(value = "/entity")
public class EntityController {
@RequestMapping(value = "/add/entityDetails.do", method = RequestMethod.GET)
public String saveEntityDetails(EntityCheckpointsVo entityCheckpointsVo) {
return "success";
}
}
我认为这个问题会在你提到servletMapping而不是实体时解决。 – Jango
它可能是未声明的HTTP方法?我在日志中看到“methods = []”。 – Berger
@Berger在这种情况下弹簧会告诉方法不支持 –