twitter bootstrap - Controller using Spark framework is nesting html in <pre> -


i'm trying use spark , freemarker framework site i'm building. now, i'm going through tutorial , trying implement bootstrap well. working in sense spark mapping resource file proper endpoint. however, reason seems nesting of html in pre element displays on endpoint raw html.

here's have:

the controller:

import static spark.spark.get;  import java.util.hashmap; import java.util.map;  import spark.modelandview; import spark.template.freemarker.freemarkerengine;  public class bulkuploadcontroller extends basecontroller {      private static final string controller_root = "/bulk-upload";      @override     public void registerendpoints() {          get(controller_root,                  (request, response) -> {                     map<string, object> attributes = new hashmap<>();                     return new modelandview(attributes, "bulk-upload.ftl");                 }, new freemarkerengine());      }  } 

the main method in apiserver.java:

public static void main(string[] args) {         apiserver apiserver = new apiserver();         apiserver.init();     }  private void init() {                setupendpoints();     }  private void setupendpoints() { bulkuploadcontroller bulkuploadcontroller = new bulkuploadcontroller(); bulkuploadcontroller.registerendpoints(); } 

my view (bulk-upload.html):

<!doctype html> <html lang="en">      <head>         <title>bulk uploader</title>         <meta charset="utf-8">         <meta name="viewport" content="width=device-width, initial-scale=1">         <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">         <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>         <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>     </head>      <body>         <div class="container">             <h1>bulk uploader</h1>             <p>other stuff go here</p>         </div>     </body>  </html> 

so of html not being set rootof endpoint, rather being nested described above. ideas why might me happening?

alright, figured out. i'll post answer here in case others confused same thing. working, needed change controller add this:

response.type("text/html"); 

so:

get(controller_root,                  (request, response) -> {                     response.type("text/html");                     map<string, object> attributes = new hashmap<>();                     attributes.put("dvfcs", new object());                     return new modelandview(attributes, "bulk-upload.ftl");                 }, new freemarkerengine());  

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -