render series method


render series methods will render different types of views and return them to the client. The view types currently supported by JFinal are:
FreeMarker, JSP, Velocity, JSON, File, Text, Html, etc. In addition to the view types supported by JFinal, you can also extend the view types infinitely by inheriting the Render abstract class.


Usually the Controller.render(String) method is used to render the view. The view type when using Controller.render(String) is determined by JFinalConfig. configConstant(Constantsconstants) is determined by constants.setViewType(ViewType) in the configuration. The ViewTypes supported by this setting method are: FreeMarker, JSP, Velocity, and the default when no configuration is performed Configured as FreeMarker.


In addition, you can also set the view used by Controller.render(String) through constants.setMainRenderFactory(IMainRenderFactory). IMainRenderFactory is specially used to The Controller.render(String) method extends views other than FreeMarker, JSP, and Velocity.

Assume that there is the following Controller mapping configuration in JFinalConfig.configRoute(Routes routes): routes.add(“/user”, UserController.class, “/path”), render(String view) usage example:


QQ截图20170206102243.png

##Other render method usage examples:


QQ截图20170206102250.png

Notice:

QQ截图20170206102257.png2: Except for the renderError method, the program will not return immediately after calling the render series of methods. If you need to return immediately, you need to use the return statement. When the render method is called multiple times in an action, only the last one is valid. 1: IE does not support the contentType of application/json. When json is returned after ajax uploads the file, IE prompts to download the file. The solution is to use: render(new JsonRender().forIE()) or render( new JsonRender(params).forIE()). This situation only occurs in IE browser ajax file upload, and other ordinary ajax requests are ignored.