java:
@Controller
public?class?MainController?{
????@Autowired
????private?UserService?userService;
????@RequestMapping(value?=?"/toLogin",?method?=?RequestMethod.GET)
????public?String?home(Model?model){
????return?"login";
????}
}配置文件:<!--?掃描controller的位置?-->
<!--?springmvc?注解驅(qū)動?-->
<mvc:annotation-driven?/>
<context:component-scan?base-package="com.tongwii.controller"?/>
<bean?id="viewResolver"
??????class="org.springframework.web.servlet.view.UrlBasedViewResolver">
????<property?name="viewClass"
??????????????value="org.springframework.web.servlet.view.JstlView"?/>
????<property?name="prefix"?value="/WEB-INF/pages"?/>
????<property?name="suffix"?value=".jsp"?/>
</bean>
<!--以下省略-->目錄結構: 項目框架是SpringMVC+hibernate
3 回答

Plan_b2
TA貢獻2條經(jīng)驗 獲得超0個贊
? <property?name="prefix"?value="/WEB-INF/pages"?/>
????<property?name="suffix"?value=".jsp"?/>
這段配置內(nèi)容在/WEB-INF/pages"后面加上"/",效果如下
? <property?name="prefix"?value="/WEB-INF/pages/"?/>
????<property?name="suffix"?value=".jsp"?/>
添加回答
舉報
0/150
提交
取消