2013-12-05 3 views
1

У меня есть запрос на REST GET, который вызывает редирект или так кажется ...шаблон Android остальное - GET запрос - Слишком много переадресаций

Вот выход журнала:

D/AndroidRuntime (1353): Завершение работы VM W/dalvikvm (1353): threadid = 1: выход с отключенным исключением (группа = 0xb2ab3b90) E/AndroidRuntime (1353): FATAL EXCEPTION: main E/AndroidRuntime (1353): Процесс: com.thalasoft .learnintouch.android, PID: 1353 E/AndroidRuntime (1353): java.lang.RuntimeException: не удается запустить активность ComponentInfo {com.thalasoft.learnintouch.android/com.thalasoft .learnintouch.android.AdminActivity}: org.springframework.web.client.ResourceAccessException: ошибка ввода-вывода: слишком много перенаправлений: 21; вложенное исключение java.net.ProtocolException: слишком много переадресаций: 21

Код клиента REST:

public class AdminActivity extends Activity { 

    private static final String REST_HOST = "10.0.2.2"; 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

     setContentView(R.layout.admin_layout); 
    } 

    @Override 
    public void onStart() { 
     super.onStart(); 

     RestTemplate restTemplate = new RestTemplate(); 
     restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); 
     HttpHeaders httpHeaders = Common.createAuthenticationHeaders("joethebouncer" + ":" + "mypassword"); 
     Admin admin = null; 
     try { 
      ResponseEntity<Admin> responseEntity = restTemplate.exchange("http://" + REST_HOST + ":8080/learnintouch-rest/admin/" + 623L, HttpMethod.GET, new HttpEntity<Object>(httpHeaders), Admin.class); 

      if (responseEntity != null) { 
       admin = responseEntity.getBody(); 
       if (admin != null) { 
        TextView textView = (TextView) this.findViewById(R.id.id); 
        textView.setText(Long.toString(admin.getId())); 

        textView = (TextView) this.findViewById(R.id.email); 
        textView.setText(admin.getEmail()); 

        textView = (TextView) this.findViewById(R.id.firstname); 
        textView.setText(admin.getFirstname()); 

        textView = (TextView) this.findViewById(R.id.lastname); 
        textView.setText(admin.getLastname()); 

        textView = (TextView) this.findViewById(R.id.login); 
        textView.setText(admin.getLogin()); 

        textView = (TextView) this.findViewById(R.id.password); 
        textView.setText(admin.getPassword()); 

        textView = (TextView) this.findViewById(R.id.passwordSalt); 
        textView.setText(admin.getPasswordSalt()); 
       } 
      } 
     } catch (HttpClientErrorException e) { 
      Log.e("Msg", ">>>>>>>>>>>>>>>> Could not request the rest service " + e.getLocalizedMessage()); 
     } 
    } 

} 

Вот контроллер Spring REST:

@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = "application/json; charset=utf-8") 
@ResponseBody 
public ResponseEntity<Admin> findOne(@PathVariable Long id, UriComponentsBuilder builder) { 
    HttpHeaders responseHeaders = new HttpHeaders(); 
    responseHeaders.add("Content-Type", "application/json; charset=utf-8"); 
    OneAdminEvent oneAdminEvent; 
    try { 
     oneAdminEvent = adminService.findById(new GetOneAdminEvent(id)); 
    } catch (NotFoundException e) { 
     return new ResponseEntity<Admin>(responseHeaders, HttpStatus.NOT_FOUND); 
    } 
    responseHeaders.setLocation(builder.path("/admin/{id}").buildAndExpand(oneAdminEvent.getEventAdmin().getId()).toUri()); 
    Admin admin = adminResourceAssembler.toResource(oneAdminEvent.getEventAdmin()); 
    ResponseEntity<Admin> responseEntity = new ResponseEntity<Admin>(admin, responseHeaders, HttpStatus.FOUND); 
    return responseEntity; 
} 

я могу вручную проверить мой сервер боковая служба REST с запросом на завивание:

curl --user joethebouncer:mypassword http://localhost:8080/learnintouch-rest/admin/623 
{"links":[{"rel":"self","href":"http://localhost:8080/learnintouch-rest/admin/623"}],"id2":null,"firstname":"Stephane","lastname":"Eybert","email":"[email protected]","login":"joethebouncer","password":"e41de4c55873f9c000f4cdaac6efd3aa","passwordSalt":"7bc7bf5f94fef7c7106afe5c3a40a2"} 

И это не делает никаких r edirect.

Здесь выход консоли на стороне сервера при запуске Andoid приложение REST GET запрос:

2013-12-05 11:12:13,446 DEBUG [DispatcherServlet] Successfully completed request 
2013-12-05 11:12:13,446 DEBUG [ExceptionTranslationFilter] Chain processed normally 
2013-12-05 11:12:13,446 DEBUG [SecurityContextPersistenceFilter] SecurityContextHolder now cleared, as request processing completed 
2013-12-05 11:12:13,471 DEBUG [AntPathRequestMatcher] Checking match of request : '/admin/623'; against '/admin/**' 
2013-12-05 11:12:13,471 DEBUG [FilterChainProxy] /admin/623 at position 1 of 9 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter' 
2013-12-05 11:12:13,471 DEBUG [HttpSessionSecurityContextRepository] No HttpSession currently exists 
2013-12-05 11:12:13,471 DEBUG [HttpSessionSecurityContextRepository] No SecurityContext was available from the HttpSession: null. A new one will be created. 
2013-12-05 11:12:13,471 DEBUG [FilterChainProxy] /admin/623 at position 2 of 9 in additional filter chain; firing Filter: 'LogoutFilter' 
2013-12-05 11:12:13,471 DEBUG [FilterChainProxy] /admin/623 at position 3 of 9 in additional filter chain; firing Filter: 'BasicAuthenticationFilter' 
2013-12-05 11:12:13,471 DEBUG [BasicAuthenticationFilter] Basic Authentication Authorization header found for user 'joethebouncer' 
2013-12-05 11:12:13,471 DEBUG [ProviderManager] Authentication attempt using com.thalasoft.learnintouch.rest.security.CustomAuthenticationProvider 
2013-12-05 11:12:13,471 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'transactionManager' 
2013-12-05 11:12:13,471 DEBUG [JpaTransactionManager] Creating new transaction with name [com.thalasoft.learnintouch.data.service.jpa.AdminServiceImpl.findByLogin]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly; '' 
2013-12-05 11:12:13,471 DEBUG [JpaTransactionManager] Opened new EntityManager [[email protected]] for JPA transaction 
2013-12-05 11:12:13,471 DEBUG [DriverManagerDataSource] Creating new JDBC DriverManager Connection to [jdbc:log4jdbc:mysql://127.0.0.1:3306/db_integration] 
2013-12-05 11:12:13,478 DEBUG [JpaTransactionManager] Exposing JPA transaction as JDBC transaction [org.springframewo[email protected]e9ac75] 
Hibernate: 
    select 
     admin0_.id as id14_, 
     admin0_.version as version14_, 
     admin0_.address as address14_, 
     admin0_.city as city14_, 
     admin0_.country as country14_, 
     admin0_.email as email14_, 
     admin0_.firstname as firstname14_, 
     admin0_.lastname as lastname14_, 
     admin0_.login as login14_, 
     admin0_.password as password14_, 
     admin0_.password_salt as password11_14_, 
     admin0_.post_login_url as post12_14_, 
     admin0_.preference_admin as preference13_14_, 
     admin0_.profile as profile14_, 
     admin0_.super_admin as super15_14_, 
     admin0_.zip_code as zip16_14_ 
    from 
     admin admin0_ 
    where 
     admin0_.login=? limit ? 
2013-12-05 11:12:13,480 TRACE [BasicBinder] binding parameter [1] as [VARCHAR] - joethebouncer 
2013-12-05 11:12:13,481 DEBUG [sqlonly] org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) 
282. select admin0_.id as id14_, admin0_.version as version14_, admin0_.address as address14_, admin0_.city 
as city14_, admin0_.country as country14_, admin0_.email as email14_, admin0_.firstname as 
firstname14_, admin0_.lastname as lastname14_, admin0_.login as login14_, admin0_.password 
as password14_, admin0_.password_salt as password11_14_, admin0_.post_login_url as post12_14_, 
admin0_.preference_admin as preference13_14_, admin0_.profile as profile14_, admin0_.super_admin 
as super15_14_, admin0_.zip_code as zip16_14_ from admin admin0_ where admin0_.login='joethebouncer' 
limit 2 
2013-12-05 11:12:13,484 TRACE [BasicExtractor] found [623] as column [id14_] 
2013-12-05 11:12:13,485 TRACE [BasicExtractor] found [0] as column [version14_] 
2013-12-05 11:12:13,486 TRACE [BasicExtractor] found [] as column [address14_] 
2013-12-05 11:12:13,486 TRACE [BasicExtractor] found [] as column [city14_] 
2013-12-05 11:12:13,487 TRACE [BasicExtractor] found [] as column [country14_] 
2013-12-05 11:12:13,488 TRACE [BasicExtractor] found [[email protected]] as column [email14_] 
2013-12-05 11:12:13,488 TRACE [BasicExtractor] found [Stephane] as column [firstname14_] 
2013-12-05 11:12:13,489 TRACE [BasicExtractor] found [Eybert] as column [lastname14_] 
2013-12-05 11:12:13,489 TRACE [BasicExtractor] found [joethebouncer] as column [login14_] 
2013-12-05 11:12:13,490 TRACE [BasicExtractor] found [e41de4c55873f9c000f4cdaac6efd3aa] as column [password14_] 
2013-12-05 11:12:13,491 TRACE [BasicExtractor] found [7bc7bf5f94fef7c7106afe5c3a40a2] as column [password11_14_] 
2013-12-05 11:12:13,491 TRACE [BasicExtractor] found [null] as column [post12_14_] 
2013-12-05 11:12:13,492 TRACE [BasicExtractor] found [false] as column [preference13_14_] 
2013-12-05 11:12:13,492 TRACE [BasicExtractor] found [] as column [profile14_] 
2013-12-05 11:12:13,493 TRACE [BasicExtractor] found [true] as column [super15_14_] 
2013-12-05 11:12:13,493 TRACE [BasicExtractor] found [] as column [zip16_14_] 
2013-12-05 11:12:13,496 DEBUG [JpaTransactionManager] Initiating transaction commit 
2013-12-05 11:12:13,496 DEBUG [JpaTransactionManager] Committing JPA transaction on EntityManager [[email protected]] 
2013-12-05 11:12:13,499 DEBUG [JpaTransactionManager] Closing JPA EntityManager [[email protected]] after transaction 
2013-12-05 11:12:13,499 DEBUG [EntityManagerFactoryUtils] Closing JPA EntityManager 
2013-12-05 11:12:13,499 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'transactionManager' 
2013-12-05 11:12:13,499 DEBUG [JpaTransactionManager] Creating new transaction with name [com.thalasoft.learnintouch.data.service.jpa.AdminServiceImpl.checkPassword]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly; '' 
2013-12-05 11:12:13,499 DEBUG [JpaTransactionManager] Opened new EntityManager [[email protected]] for JPA transaction 
2013-12-05 11:12:13,499 DEBUG [DriverManagerDataSource] Creating new JDBC DriverManager Connection to [jdbc:log4jdbc:mysql://127.0.0.1:3306/db_integration] 
2013-12-05 11:12:13,507 DEBUG [JpaTransactionManager] Exposing JPA transaction as JDBC transaction [org.springframewo[email protected]16354d0] 
2013-12-05 11:12:13,507 DEBUG [JpaTransactionManager] Initiating transaction commit 
2013-12-05 11:12:13,507 DEBUG [JpaTransactionManager] Committing JPA transaction on EntityManager [[email protected]] 
2013-12-05 11:12:13,509 DEBUG [JpaTransactionManager] Closing JPA EntityManager [[email protected]] after transaction 
2013-12-05 11:12:13,509 DEBUG [EntityManagerFactoryUtils] Closing JPA EntityManager 
2013-12-05 11:12:13,509 DEBUG [BasicAuthenticationFilter] Authentication success: org.springframew[email protected]833e8985: Principal: joethebouncer; Credentials: [PROTECTED]; Authenticated: true; Details: org.sprin[email protected]957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: ROLE_ADMIN 
2013-12-05 11:12:13,509 DEBUG [FilterChainProxy] /admin/623 at position 4 of 9 in additional filter chain; firing Filter: 'RequestCacheAwareFilter' 
2013-12-05 11:12:13,509 DEBUG [FilterChainProxy] /admin/623 at position 5 of 9 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter' 
2013-12-05 11:12:13,509 DEBUG [FilterChainProxy] /admin/623 at position 6 of 9 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter' 
2013-12-05 11:12:13,509 DEBUG [AnonymousAuthenticationFilter] SecurityContextHolder not populated with anonymous token, as it already contained: 'org.springframew[email protected]833e8985: Principal: joethebouncer; Credentials: [PROTECTED]; Authenticated: true; Details: org.sprin[email protected]957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: ROLE_ADMIN' 
2013-12-05 11:12:13,509 DEBUG [FilterChainProxy] /admin/623 at position 7 of 9 in additional filter chain; firing Filter: 'SessionManagementFilter' 
2013-12-05 11:12:13,509 DEBUG [HttpSessionSecurityContextRepository] HttpSession being created as SecurityContext is non-default 
2013-12-05 11:12:13,509 DEBUG [HttpSessionSecurityContextRepository] SecurityContext stored to HttpSession: '[email protected]3e8985: Authentication: org.springframew[email protected]833e8985: Principal: joethebouncer; Credentials: [PROTECTED]; Authenticated: true; Details: org.sprin[email protected]957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: ROLE_ADMIN' 
2013-12-05 11:12:13,510 DEBUG [FilterChainProxy] /admin/623 at position 8 of 9 in additional filter chain; firing Filter: 'ExceptionTranslationFilter' 
2013-12-05 11:12:13,510 DEBUG [FilterChainProxy] /admin/623 at position 9 of 9 in additional filter chain; firing Filter: 'FilterSecurityInterceptor' 
2013-12-05 11:12:13,510 DEBUG [FilterSecurityInterceptor] Secure object: FilterInvocation: URL: /admin/623; Attributes: [hasRole('ROLE_ADMIN')] 
2013-12-05 11:12:13,510 DEBUG [FilterSecurityInterceptor] Previously Authenticated: org.springframew[email protected]833e8985: Principal: joethebouncer; Credentials: [PROTECTED]; Authenticated: true; Details: org.sprin[email protected]957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: ROLE_ADMIN 
2013-12-05 11:12:13,510 DEBUG [AffirmativeBased] Voter: org.sp[email protected]115654d, returned: 1 
2013-12-05 11:12:13,510 DEBUG [FilterSecurityInterceptor] Authorization successful 
2013-12-05 11:12:13,510 DEBUG [FilterSecurityInterceptor] RunAsManager did not change Authentication object 
2013-12-05 11:12:13,510 DEBUG [FilterChainProxy] /admin/623 reached end of additional filter chain; proceeding with original chain 
2013-12-05 11:12:13,510 DEBUG [DispatcherServlet] DispatcherServlet with name 'dispatcher' processing GET request for [/learnintouch-rest/admin/623] 
2013-12-05 11:12:13,510 DEBUG [RequestMappingHandlerMapping] Looking up handler method for path /admin/623 
2013-12-05 11:12:13,511 DEBUG [RequestMappingHandlerMapping] Returning handler method [public org.springframework.http.ResponseEntity<com.thalasoft.learnintouch.rest.domain.Admin> com.thalasoft.learnintouch.rest.controller.AdminController.findOne(java.lang.Long,org.springframework.web.util.UriComponentsBuilder)] 
2013-12-05 11:12:13,511 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'adminController' 
2013-12-05 11:12:13,511 DEBUG [DispatcherServlet] Last-Modified value for [/learnintouch-rest/admin/623] is: -1 
2013-12-05 11:12:13,511 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'transactionManager' 
2013-12-05 11:12:13,511 DEBUG [JpaTransactionManager] Creating new transaction with name [com.thalasoft.learnintouch.data.service.jpa.AdminServiceImpl.findById]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly; '' 
2013-12-05 11:12:13,511 DEBUG [JpaTransactionManager] Opened new EntityManager [[email protected]] for JPA transaction 
2013-12-05 11:12:13,512 DEBUG [DriverManagerDataSource] Creating new JDBC DriverManager Connection to [jdbc:log4jdbc:mysql://127.0.0.1:3306/db_integration] 
2013-12-05 11:12:13,520 DEBUG [JpaTransactionManager] Exposing JPA transaction as JDBC transaction [org.springframewo[email protected]a709f3] 
2013-12-05 11:12:13,520 DEBUG [DefaultListableBeanFactory] Returning cached instance of singleton bean 'transactionManager' 
2013-12-05 11:12:13,520 DEBUG [JpaTransactionManager] Found thread-bound EntityManager [[email protected]] for JPA transaction 
2013-12-05 11:12:13,520 DEBUG [JpaTransactionManager] Participating in existing transaction 
Hibernate: 
    select 
     admin0_.id as id14_0_, 
     admin0_.version as version14_0_, 
     admin0_.address as address14_0_, 
     admin0_.city as city14_0_, 
     admin0_.country as country14_0_, 
     admin0_.email as email14_0_, 
     admin0_.firstname as firstname14_0_, 
     admin0_.lastname as lastname14_0_, 
     admin0_.login as login14_0_, 
     admin0_.password as password14_0_, 
     admin0_.password_salt as password11_14_0_, 
     admin0_.post_login_url as post12_14_0_, 
     admin0_.preference_admin as preference13_14_0_, 
     admin0_.profile as profile14_0_, 
     admin0_.super_admin as super15_14_0_, 
     admin0_.zip_code as zip16_14_0_ 
    from 
     admin admin0_ 
    where 
     admin0_.id=? 
2013-12-05 11:12:13,522 TRACE [BasicBinder] binding parameter [1] as [BIGINT] - 623 
2013-12-05 11:12:13,523 DEBUG [sqlonly] org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) 
284. select admin0_.id as id14_0_, admin0_.version as version14_0_, admin0_.address as address14_0_, 
admin0_.city as city14_0_, admin0_.country as country14_0_, admin0_.email as email14_0_, admin0_.firstname 
as firstname14_0_, admin0_.lastname as lastname14_0_, admin0_.login as login14_0_, admin0_.password 
as password14_0_, admin0_.password_salt as password11_14_0_, admin0_.post_login_url as post12_14_0_, 
admin0_.preference_admin as preference13_14_0_, admin0_.profile as profile14_0_, admin0_.super_admin 
as super15_14_0_, admin0_.zip_code as zip16_14_0_ from admin admin0_ where admin0_.id=623 
2013-12-05 11:12:13,527 TRACE [BasicExtractor] found [0] as column [version14_0_] 
2013-12-05 11:12:13,528 TRACE [BasicExtractor] found [] as column [address14_0_] 
2013-12-05 11:12:13,529 TRACE [BasicExtractor] found [] as column [city14_0_] 
2013-12-05 11:12:13,529 TRACE [BasicExtractor] found [] as column [country14_0_] 
2013-12-05 11:12:13,531 TRACE [BasicExtractor] found [[email protected]] as column [email14_0_] 
2013-12-05 11:12:13,532 TRACE [BasicExtractor] found [Stephane] as column [firstname14_0_] 
2013-12-05 11:12:13,532 TRACE [BasicExtractor] found [Eybert] as column [lastname14_0_] 
2013-12-05 11:12:13,533 TRACE [BasicExtractor] found [joethebouncer] as column [login14_0_] 
2013-12-05 11:12:13,534 TRACE [BasicExtractor] found [e41de4c55873f9c000f4cdaac6efd3aa] as column [password14_0_] 
2013-12-05 11:12:13,535 TRACE [BasicExtractor] found [7bc7bf5f94fef7c7106afe5c3a40a2] as column [password11_14_0_] 
2013-12-05 11:12:13,536 TRACE [BasicExtractor] found [null] as column [post12_14_0_] 
2013-12-05 11:12:13,537 TRACE [BasicExtractor] found [false] as column [preference13_14_0_] 
2013-12-05 11:12:13,537 TRACE [BasicExtractor] found [] as column [profile14_0_] 
2013-12-05 11:12:13,538 TRACE [BasicExtractor] found [true] as column [super15_14_0_] 
2013-12-05 11:12:13,539 TRACE [BasicExtractor] found [] as column [zip16_14_0_] 
2013-12-05 11:12:13,543 DEBUG [JpaTransactionManager] Initiating transaction commit 
2013-12-05 11:12:13,543 DEBUG [JpaTransactionManager] Committing JPA transaction on EntityManager [[email protected]] 
2013-12-05 11:12:13,546 DEBUG [JpaTransactionManager] Closing JPA EntityManager [[email protected]] after transaction 
2013-12-05 11:12:13,546 DEBUG [EntityManagerFactoryUtils] Closing JPA EntityManager 
2013-12-05 11:12:13,555 DEBUG [HttpSessionSecurityContextRepository] SecurityContext stored to HttpSession: '[email protected]3e8985: Authentication: org.springframew[email protected]833e8985: Principal: joethebouncer; Credentials: [PROTECTED]; Authenticated: true; Details: org.sprin[email protected]957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: ROLE_ADMIN' 
2013-12-05 11:12:13,556 DEBUG [HttpSessionSecurityContextRepository] SecurityContext stored to HttpSession: '[email protected]3e8985: Authentication: org.springframew[email protected]833e8985: Principal: joethebouncer; Credentials: [PROTECTED]; Authenticated: true; Details: org.sprin[email protected]957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: ROLE_ADMIN' 
2013-12-05 11:12:13,556 DEBUG [HttpEntityMethodProcessor] Written [links: [<http://10.0.2.2:8080/learnintouch-rest/admin/623>;rel="self"]] as "application/json;charset=utf-8" using [org.springfr[email protected]b72a5e] 
2013-12-05 11:12:13,556 DEBUG [DispatcherServlet] Null ModelAndView returned to DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed request handling 
2013-12-05 11:12:13,556 DEBUG [DispatcherServlet] Successfully completed request 
2013-12-05 11:12:13,556 DEBUG [ExceptionTranslationFilter] Chain processed normally 
2013-12-05 11:12:13,556 DEBUG [SecurityContextPersistenceFilter] SecurityContextHolder now cleared, as request processing completed 

Кроме того, Wireshark показывает только эти два кадра: требуемое количество раз

No.  Time   Source    Destination   Protocol Length Info 
    320 20.659878000 127.0.0.1    127.0.0.1    HTTP  375 GET /learnintouch-rest/admin/623 HTTP/1.1 

Frame 320: 375 bytes on wire (3000 bits), 375 bytes captured (3000 bits) on interface 0 
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00) 
Internet Protocol Version 4, Src: 127.0.0.1 (127.0.0.1), Dst: 127.0.0.1 (127.0.0.1) 
Transmission Control Protocol, Src Port: 57253 (57253), Dst Port: http-alt (8080), Seq: 1, Ack: 1, Len: 309 
Hypertext Transfer Protocol 

No.  Time   Source    Destination   Protocol Length Info 
    427 20.741684000 127.0.0.1    127.0.0.1    HTTP  71  HTTP/1.1 302 Found (application/json) 

Frame 427: 71 bytes on wire (568 bits), 71 bytes captured (568 bits) on interface 0 
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00) 
Internet Protocol Version 4, Src: 127.0.0.1 (127.0.0.1), Dst: 127.0.0.1 (127.0.0.1) 
Transmission Control Protocol, Src Port: http-alt (8080), Dst Port: 57253 (57253), Seq: 615, Ack: 310, Len: 5 
[2 Reassembled TCP Segments (619 bytes): #425(614), #427(5)] 
Hypertext Transfer Protocol 
JavaScript Object Notation: application/json 

No.  Time   Source    Destination   Protocol Length Info 
    429 20.794399000 127.0.0.1    127.0.0.1    HTTP  375 GET /learnintouch-rest/admin/623 HTTP/1.1 

Frame 429: 375 bytes on wire (3000 bits), 375 bytes captured (3000 bits) on interface 0 
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00) 
Internet Protocol Version 4, Src: 127.0.0.1 (127.0.0.1), Dst: 127.0.0.1 (127.0.0.1) 
Transmission Control Protocol, Src Port: 57253 (57253), Dst Port: http-alt (8080), Seq: 310, Ack: 620, Len: 309 
Hypertext Transfer Protocol 

No.  Time   Source    Destination   Protocol Length Info 
    517 20.872213000 127.0.0.1    127.0.0.1    HTTP  71  HTTP/1.1 302 Found (application/json) 

Frame 517: 71 bytes on wire (568 bits), 71 bytes captured (568 bits) on interface 0 
Ethernet II, Src: 00:00:00_00:00:00 (00:00:00:00:00:00), Dst: 00:00:00_00:00:00 (00:00:00:00:00:00) 
Internet Protocol Version 4, Src: 127.0.0.1 (127.0.0.1), Dst: 127.0.0.1 (127.0.0.1) 
Transmission Control Protocol, Src Port: http-alt (8080), Dst Port: 57253 (57253), Seq: 1234, Ack: 619, Len: 5 
[2 Reassembled TCP Segments (619 bytes): #515(614), #517(5)] 
Hypertext Transfer Protocol 
JavaScript Object Notation: application/json 

Любой ключ?

Уважение,

+0

я теперь вижу код состояния 302 запуска редирект в заголовке Location я обеспечиваю, как это предусмотрено спецификацией. Я пропустил это. Теперь я должен увидеть, какой код состояния я должен вернуть. – Stephane

+0

Код состояния http FOUND 302 используется для инициирования перенаправления на перемещенный временно ресурс. Не то, что я хотел здесь. Вместо этого я буду использовать код состояния OK 200. – Stephane

+0

как именно вы это исправили? @stephane – Hades

ответ

0

Код состояния HTTP НАЙДЕН 302 используются для запуска перенаправления на перемещенное временно ресурсы. Не то, что я хотел здесь. Вместо этого я буду использовать код состояния OK 200.

Вот как REST ответ контроллер теперь выглядит следующим образом:

ResponseEntity<Admin> responseEntity = new ResponseEntity<Admin>(admin, responseHeaders, HttpStatus.OK); 
Смежные вопросы