菜鳥當自強
SpringMVC 使用Tag標籤方法
1.建立專案Dynamic Web Project
2.拷貝相關jar包並導入
3.建立resources關聯檔案還有WebContent/WEB-INF/classes
4.在resources下建立設定application.xml
`
<context:component-scan base-package="com.tag.show"></context:component-scan>
<mvc:annotation-driven></mvc:annotation-driven>
`
6.建立xxxxController
`public ModelAndView TegMethodRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
System.out.println("TagMethodController.TegMethodRequest()");
return nu;;
}`
7.設定application.xml
<context:component-scan base-package="packageName"</context:component-scan>
<mvc:annotation-driven></mvc:annotation-driven>
8.設定tomcat sever.xml <Context docBase="webContent路徑" path="">
9.Restart Tomcat測試成功後Eclipse Console下會出現訊息如下
10.Request有反應後開始建立ModelAndView
ModelAndView mv = new ModelAndView();
mv.addObject("msg","TagMethodReview");
mv.setViewName("/tagview.jsp");
return mv;
xxx.jsp使用JSTL呈現參數值
${msg}