I am writing a website, Spring MVC

For the frontend is responsible bootstrap + JSP

Here is the task, the user creates a new topic on the forum (for example: Let's discuss the policy)

Accordingly, a new view should appear with a new address "/ newPage1" How to implement it?

  • You should have one template for all topics, and after the request, look (read from the database) what you need to put in this template. It’s a good idea to physically create a file for each topic - Mikhail Ketov

1 answer 1

Create a standard jsp for all themes, ala:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <html> <head> <title>${subject.name}</title> </head> <body> <div> ${subject.text} </div> </body> </html> 

And upon request on the topic fill it

 @RequestMapping(value = "/subject", method = RequestMethod.GET) public String deleteBasketProduct(@RequestParam("subject") String subjectName, ModelAndView modelAndView) { DataBase db = new DataBase(); //Ваше собственное реализованное хранилище, которое будет возвращать хранимую тему Subject sb = db.getSubject(subjectName); //Ваша модель темы modelAndView.addObject("subject", sb); return "subjectName.jsp"; } 
  • one
    And even better, as Michael said. Store in the database all the data on the topic and already fill out the standard jsp upon request to it. - Arthur