레거시 Struts 1.x 웹 응용 프로그램을 AngularJS + Java RESTful 웹 서비스로 마이그레이션하는 경우 얼마나 많은 작업이 필요할지 생각하고 있습니다. (Struts 1.x가 AngularJS와 잘 맞지 않는다는 것을 알고 있습니다.)Struts1 JSON 응답 ActionForm
내가 가장 먼저 주목해야 할 것은 많은 Struts ActionForm
이 있으며 JSON에서 응답을 얻는 쉬운 방법이 있는지 궁금합니다. 체재. 그래서 우리는이 많은 것 클래스가 :
public class Note extends org.apache.struts.action.ActionForm{
//setter and getter...
}
내가 POJO 스타일의 클래스에이 변환을 시도하고 너무 많은 다른 변경뿐만 아니라 DAO, 도우미, 유틸리티 클래스 필요합니다. 뭔가 피할 수없는 것이 있습니까? 아니면 먼저 Struts 2로 마이그레이션 한 다음 AngularJS를 채택하는 것이 좋습니다.
org.codehaus.jackson.map.JsonMappingException : 내가 응답을하려고 할 때
는 그런데, 나는 일식 콘솔에서이 오류가없는 클래스 org.apache.struts.action를 찾지 시리얼을 .ActionServletWrapper하고 발견 없음 속성 (SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS 비활성화 예외를 피하기 위해)) (참조 체인을 통해 BeanSerializer를 만들려면 org.kki.dao.oracle.ads.TranscribedNote [ "servletWrapper를"])
업데이트 :
,210@Path("/note")
public class NoteRestService {
@Context
private HttpServletRequest request;
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Note [] getNote() {
HttpSession session = request.getSession();
User user = (User) session.getAttribute("user");
NoteDAO noteDao = new NoteDAO(null);
Note[] note = noteDao.selectNote(user.getUserId());
return note;
}
}
=========
myApp.controller('noteCtrl', ['$scope', 'Note',
function ($scope, Note) {
var vm = this;
$scope.noteLists = Note.query(function(){
vm.noteList = $scope.noteLists;
});
================
myApp.factory('Note', ['$resource',
function($resource) {
return $resource('http://localhost:8080/angular_demo/rest/note/:id', {id: '@id'}, {
get: {method: 'GET', cache: false, isArray: false}
});
}]);
어떻게 응답을 json 형식으로 반환 했습니까? –
방금 원래 질문을 편집했습니다. – Daniel
아래 답변입니다. –