javascript - Could not make json data on spring 3.2 and got an error (Page not found 404) -
i trying select data database using sprng 3.2, mybatis , want receive data formatted json.
i put jackson-core-asl, jackson-core-lgpl , jackson-mapper-asl(1.9.13) in pom.xml
when send request server, got error "http status 404 - /web-inf/jsp/listjson.jsp" . wonder why configuration file doesn't work @responsebody.
i googled lot still have error. doesn't work on spring 3.2?
when put below instead of <mvc:annotation-driven />
works well. know annotationmethodhandleradapter deprecated on spring 3.2.
<beans:bean class="org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter"> <beans:property name="messageconverters"> <beans:list> <beans:bean class="org.springframework.http.converter.json.mappingjacksonhttpmessageconverter" /> </beans:list> </beans:property>
- servlet-context.xml
<mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="prefix" value="/web-inf/jsp/" /> <property name="suffix" value=".jsp" /> </bean>
2 controller
@controller public class boardcontroller { @autowired private mainservice mainservice; @requestmapping("/listjson.do") public @responsebody map<?, ?> listjson(@requestparam map<string, object> parammap, modelmap model) throws throwable { model.put("results", mainservice.getlist(parammap)); return model; } }
the following configuration works me!
just put <mvc:annotation-driven>
not enough render json format data. , in tomcat log console,i found handlermapping in use requestmappinghandlermapping
<mvc:annotation-driven /> <beans:bean class="org.springframework.web.servlet.view.contentnegotiatingviewresolver"> <beans:property name="mediatypes"> <beans:map> <beans:entry key="html" value="text/html" /> <beans:entry key="json" value="application/json" /> </beans:map> </beans:property> <beans:property name="viewresolvers"> <beans:bean class="org.springframework.web.servlet.view.internalresourceviewresolver"> <beans:property name="prefix" value="/web-inf/views/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> </beans:property> <beans:property name="defaultviews"> <beans:list> <beans:bean class="org.springframework.web.servlet.view.json.mappingjackson2jsonview" /> </beans:list> </beans:property> </beans:bean>
Comments
Post a Comment