PDF auf einer Webseite anzeigen

Ich benutze Spring MVC,Ich möchte eine PDF-Datei von meiner lokalen Webseite anzeigen. Ich weiß nicht, was ich mit meinem Controller tun soll, um dies zu tun. Ich sehe ein ähnliches Problem mit einer Antwort, die a zurückgibtResponseEntity<byte[]> wie in diesemFrage aber dieser ist fürajax Wenn ich mich nicht irre, ist das nicht meine Anforderung.

Aktualisieren:

Das habe ich bisher versucht:

<a href="#" onClick="test();" >test</a>

function test(){
      $.ajax({
    type: "POST",
    url: "../admin/module/id.do",
    data: '{ file_id }',
    success: function(response){
           alert(response);
             }
      });
}

Und der Controller:

@RequestMapping( value = "/admin/module/id", method = RequestMethod.POST )
    public ResponseEntity<byte[]> getPDF( @PathVariable( "id" )
    int id, Model model )
    {
        System.out.println( "test" );
        Path path = Paths.get( "C:/Users/FORSAK~1/AppData/Local/Temp/spring_tutorial.pdf" );
        byte[] contents = null;
        try
        {
            contents = Files.readAllBytes( path );
        }
        catch( IOException e )
        {

            e.printStackTrace();
        }
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType( MediaType.parseMediaType( "application/pdf" ) );
        String filename = "spring_tutorial.pdf";
        headers.setContentDispositionFormData( filename, filename );
        ResponseEntity<byte[]> response = new ResponseEntity<byte[]>( contents, headers, HttpStatus.OK );
        return response;
    }

dasalert(response) funktioniert nicht und auch dieSystem.out.println( "test" );

Der Fehler vom Firebug ist"NetworkError: 500 Internal Server Error - http://localhost:8080/ThesisProject/admin/module/id.do"

Stacktrace:

java.lang.IllegalStateException: Could not find @PathVariable [id] in @RequestMapping
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter$ServletHandlerMethodInvoker.resolvePathVariable(AnnotationMethodHandlerAdapter.java:857)
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolvePathVariable(HandlerMethodInvoker.java:710)
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:360)
    at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:444)
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:432)
    ....

Antworten auf die Frage(1)

Ihre Antwort auf die Frage