想使用jsp:include ..但是jsp是通过spring控制器返回的(查看解析器)

时间:2016-05-18 10:52:47

标签: java spring jsp spring-mvc controller

我修改了我的问题。

(index.jsp,willwork.jsp,WillWorkcontroller.java,另一个控制器)

我有一个Spring控制器,它通过视图解析器返回一个JSP。 (我的意思是......从coltroller转到jsp) 我想在主jsp中包含willwork.jsp

但是,willwork.jsp必须通过控制器返回! 所以我不知道如何在index.jsp中使用

这是我的代码

主jsp - &gt;在contextPath中 <div class ="contents"> <jsp:include page="${page}".jsp flush="false"></jsp:include> //it's wrong </div>

WillWork.java(contoller) - &gt;包名:com.we2.willwork

@Controller
public class WillWorkController {

    private WillWorkDAO2 willWorkDAO;
    public void setWillWorkDAO(WillWorkDAO2 willWorkDAO) {
        this.willWorkDAO = willWorkDAO;
    }

    @RequestMapping(value="/willwork", method=RequestMethod.GET)
    public String initGet(Model model) throws ParseException{
    List<WillWorkVO> results = willWorkDAO.selectAll(); ...return "/WillWork/WillWork";

Willwork.jsp - &gt;在WillWork文件夹中

another controller! -> it returns main page and include page that will be included

@RequestMapping(value="/mailtest", method=RequestMethod.GET)
public String pjt(Model model, String category) {
    model.addAttribute("page1","../WillWork/WillWork.jsp");
    return "myproject/myproject";
}

1 个答案:

答案 0 :(得分:0)

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Dim TEST As String = "ONE\TWO\TRHREE\FOR\FIVE"
    Dim splitted = TEST.Split("\"c)
    Dim values = splitted.Skip(1).Take(splitted.Length - 2).ToArray()
    MsgBox(values)
End Sub

CommonHeader是web_inf / views / CommonHeader

中的文件夹

这包含在web_inf / views / student / student.jsp这个JSP文件中。

..在我的情况下指的是视图文件夹,我的两个jsp文件夹都存在