3月16日
9553 ワード
apachetomcatバージョンのサーブレット、jsp specに従います.
https://tomcat.apache.org/whichversion.html
WEB-INFでは、viewフォルダにjspを作成します.
WEB-INFでは、ブラウザから直接アクセスできず、webappのみアクセスできます.したがって、jspは現在直接アクセスできません.(MVCモード自体はサーブレットからjspを要求するものである.)
作成したSpring beanプロファイルは、その2つのファイルとして自動的に作成されます.
context-paramとinit-paramの違い
context-paramはグローバル変数のようにinit-paramはローカル変数のように
1.webテクノロジーと非web環境で使用されるbeanの両方にxmlを使用します.Servlet-context.xmlに格納されます.
2.Webに対応するサーブレット-context.xmlに対応する非webはroot-contextに格納される.
HomeControllerを自動的に作成します.@Controller,@RequestMappingを使用して作成し,削除する.
複数の空の登録web.xmlを変更します.paramvalue
コンソールウィンドウのマッピング値がこの場合、コントローラに問題はありません.表示されない場合は、xmlに登録されていることを確認します.
https://tomcat.apache.org/whichversion.html
WEB-INFでは、viewフォルダにjspを作成します.
WEB-INFでは、ブラウザから直接アクセスできず、webappのみアクセスできます.したがって、jspは現在直接アクセスできません.(MVCモード自体はサーブレットからjspを要求するものである.)
作成したSpring beanプロファイルは、その2つのファイルとして自動的に作成されます.
context-paramとinit-paramの違い
context-paramはグローバル変数のようにinit-paramはローカル変数のように
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
SpringはBeanを登録します.1.webテクノロジーと非web環境で使用されるbeanの両方にxmlを使用します.Servlet-context.xmlに格納されます.
2.Webに対応するサーブレット-context.xmlに対応する非webはroot-contextに格納される.
HomeControllerを自動的に作成します.@Controller,@RequestMappingを使用して作成し,削除する.
@Controller
public class HomeController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
/**
* Simply selects the home view to render by returning its name.
*/
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
logger.info("Welcome home! The client locale is {}.", locale);
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
String formattedDate = dateFormat.format(date);
model.addAttribute("serverTime", formattedDate );
return "home";
}
}
Spring MVCモード複数の空の登録web.xmlを変更します.paramvalue
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/appServlet/servlet-context.xml
/WEB-INF/spring/appServlet/hello-context.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
xmlが多ければ引き分けます. <param-value>
/WEB-INF/spring/appServlet/*-context.xml
</param-value>
またはxmlを作成すると、すべてのxmlファイルが参照されます.コンソールウィンドウのマッピング値がこの場合、コントローラに問題はありません.表示されない場合は、xmlに登録されていることを確認します.
INFO : Mapped URL path [/list] onto handler 'controller'
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/list.*] onto handler 'controller'
INFO : org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Mapped URL path [/list/] onto handler 'controller'
Reference
この問題について(3月16日), 我々は、より多くの情報をここで見つけました https://velog.io/@qljy22/3월-16일テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol