In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to configure Controller". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Controller is the control part of MVC, the main function is to receive the request submitted by the client, then call the function of Service and get data, and finally return View (view, that is, JSP or freemarker page).
In Jspxcms, Controller is divided into foreground and background. The foreground is the page browsed by ordinary users, using freemarker as the view, usually does not need to log in, such as the website home page, column page, special page, search page, etc.; in the background, generally for the management function, using JSP as the view, the administrator is required to log in to the background and have the corresponding permissions before access.
Background Controller configuration
/ src/main/resources/conf/plugin/plug/backend.xml
Files that conform to the rules of classpath:conf/**/backend*.xml are loaded as configuration files for background Controller.
This configuration automatically loads all classes with Controller or ControllerAdvice annotations under the com.jspxcms.plug.web.back package.
The background Controller returns the JSP page with the prefix / WEB-INF/views/ and .jsp of the JSP path, and the corresponding configuration file is / src/main/resources/application.properties.
# background JSP address prefix spring.mvc.view.prefix=/WEB-INF/views/# background JSP address suffix spring.mvc.view.suffix=.jsp background Controller class
The background access address takes / cmscp as the root path, and the final access address configured with @ RequestMapping ("/ plug/resume") and @ RequestMapping ("list.do") is / cmscp/plug/resume/list.do.
The / cmscp path is set by the code new ServletRegistrationBean (backendDispatcherServlet (), "/ cmscp/*") in com.jspxcms.core.Application.
Background Controller returns a JSP page, such as plug/resume/resume_list, with a prefix and suffix, and the actual file address is / WEB-INF/views/plug/resume/resume_list.jsp.
Package com.jspxcms.plug.web.back;@Controller@RequestMapping ("/ plug/resume") public class ResumeController {@ RequiresPermissions ("plug:resume:list") @ RequestMapping ("list.do") public String list (...) {. Return "plug/resume/resume_list";} @ RequiresPermissions ("plug:resume:create") @ RequestMapping ("create.do") public String create (...) {. Return "plug/resume/resume_form";}.} foreground Controller configuration
@ ComponentScan ({"com.jspxcms.plug.web.fore"}) in com.jspxcms.plug.ContextConfig loads the @ Controller class in the com.jspxcms.plug.web.fore package.
The view returned by the foreground Controller is FreeMarker, and the configuration of FreeMarker is in src/main/resources/context.xml.
Where templateLoaderPath is the template storage path, that is, the template prefix, and defaults to / template.
Square_bracket ${freemarkerConfig.template_update_delay} UTF-8 UTF-8 false zh_CN true,false yyyy-MM-dd'T'HH:mm:ss yyyy-MM-dd HH:mm:ss. Front desk # true / spring.ftl as s Controller class
The foreground access address directly takes the website root path as the relative path, and the access address configured by @ RequestMapping (value = "/ resume") is / resume.
The FreeMarker template path returned by the frontend, which generally returns the template path of the current site, such as / 1/default/plug_resume.html, with the template prefix, and the actual address is / template/1/default/plug_resume.html
It can also be any value, such as: / abc/def.html, with the template prefix, and the actual address is / template/abc/def.html.
Package com.jspxcms.plug.web.fore;@Controllerpublic class ResumeController {public static final String TEMPLATE = "plug_resume.html"; @ RequestMapping (value = "/ resume") public String form (HttpServletRequest request, org.springframework.ui.Model modelMap) {. / / put generic objects into modelMap, such as ctx dy user site global Map data = modelMap.asMap (); ForeContext.setData (data, request) / / get the current site object Site site = Context.getCurrentSite (); / / return the current site template path. For example: / 1/default/plug_resume.html. With the template prefix, the actual address is / template/1/default/plug_resume.html return site.getTemplate (TEMPLATE);} @ RequestMapping (value = "/ resume", method = RequestMethod.POST) public String submit (.) {.}} "how to configure Controller" is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.