相关疑难解决方法(0)

java.lang.NoClassDefFoundError:当我向控制器发送无效值时javax/el/PropertyNotFoundException

我使用MockMvc进行控制器测试

@Test
    public void updateEvent() throws Exception{
        MockHttpServletRequestBuilder request = MockMvcRequestBuilders
                .post("/updateEvent");
        request.param("selectedEventStatusId", "1");
        request.param("selectedEventTypeId", "1");



        Event eventFromDb = createAndSaveEvent();
        request.param("idEvent", eventFromDb.getId().toString());
        request.param("name", eventFromDb.getName());
        request.param("description", eventFromDb.getDescription() +"____");//the reason of problem. if I will write request.param("description", eventFromDb.getDescription() );  its good work mapping if this field below
        request.param("date", new SimpleDateFormat("yyyy-MM-dd").format(eventFromDb.getDate()));
        request.param("eventDate", new SimpleDateFormat("yyyy-MM-dd").format(eventFromDb.getEventDate()));


        ResultActions result = mockMvc.perform(request).andDo(MockMvcResultHandlers.print());

        result.andExpect(MockMvcResultMatchers.view().name("redirect:eventDetails"));
        result.andExpect(MockMvcResultMatchers.model().attributeExists("idEvent"));
        result.andExpect(MockMvcResultMatchers.model().attributeExists("message"));

    }
Run Code Online (Sandbox Code Playgroud)

描述字段标记为

    @Size(min=5)
    @Pattern(regexp="[a-zA-Z]*")    
    private String description;
Run Code Online (Sandbox Code Playgroud)

我在执行后看到下一个stackTrace:

 org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: javax/el/PropertyNotFoundException
        at org.springframework.web.servlet.DispatcherServlet.triggerAfterCompletionWithError(DispatcherServlet.java:1259)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
        at …
Run Code Online (Sandbox Code Playgroud)

java testing validation hibernate spring-mvc

11
推荐指数
3
解决办法
3万
查看次数

标签 统计

hibernate ×1

java ×1

spring-mvc ×1

testing ×1

validation ×1