會員註冊 / 登入  |  電腦版  |  Jump to bottom of page

User Forum » How to add jforum in sub-directory in webapp

發表人: Amy
6 年 前
I have a maven webapp (say rootApp ) I want to add jforum to rootApp/forum path.

  • I installed jforum initially to set up the database and then copied the files in it to rootApp/forum.

  • I copied content of rootApp/forum/WEB-INF/ to rootApp/WEB-INF/

  • I copied rootApp/forum/templates directory to rootApp/


  • But when I go to rootApp/forum/ it redirects and the forum is executed on rootApp. I want all the URL's to be on rootApp/forum/.... How to achieve this?

    發表人: udittmer
    6 年 前
    I haven't tried this, but a few things come to mind:

  • In web.xml, CSRFGuard probably needs to map to /forum/*


  • You need to ensure that there are no *.ftl and *.page URLs elsewhere in the web app


  • There are a few entries in jforum-custom.conf that need to be adapted; at the least forum.link, homepage.link and context.path

  • 發表人: Amy
    6 年 前
    I tried all those and a lot more, but couldn't get it through smilie

    I believe the problem is that I copied the templates directory in the root, so I put it back inside src/main/webapp/forum but now it throws an exception saying path "...src/main/webapp/templates" cannot be found.

    How can I update the context path for jforum so that it includes "forum/"?

    發表人: udittmer
    6 年 前
    That could be the context.path entry I mentioned in config/jforum-custom.conf. The problem I see is that "context path" has a specific meaning for Java web apps (for the root web app it would be "/" which can't be changed), and I'm not sure that changing it in that config file would accomplish the right thing. No harm, on trying, I guess.

    發表人: Amy
    6 年 前
    I changed the context.path and forum.link in https://github.com/sachi-d/JForumDemo/blob/master/src/main/webapp/WEB-INF/config/jforum-custom.conf.
    And changed the forum.link in SystemGlobals.properties file too.

    But now when I go to /myforum/, I'm redirected to myforum/forums/list.page but it shows nothing (I commented the CSRF filtering). It should give out something because the "templates" is is inside "/myforum/". But if I explicitly go to root/forums/list.page it shows the content (because the "templates" directory is in the root).

    The redirection is correct, but it does not read the "templates" inside "myforum". Any help please?

    The project code: https://github.com/sachi-d/JForumDemo

    發表人: udittmer
    6 年 前
    I don't think moving the templates directory is a good idea. I'm fairly certain that the code makes assumptions about where it is.

    but it shows nothing

    Anything in the log files, either JForum or server?

    發表人: udittmer
    6 年 前
     
    udittmer wrote:I'm fairly certain that the code makes assumptions about where it is.


    Indeed it does. It is assumed to be in the "templates" directory that is in the root directory.

    發表人: Amy
    6 年 前
     
    udittmer wrote:
    udittmer wrote:I'm fairly certain that the code makes assumptions about where it is.


    Indeed it does. It is assumed to be in the "templates" directory that is in the root directory.


    Where is that configuration? Can I change it to set it to look inside root/myforum/

    發表人: udittmer
    6 年 前
    That is hard-coded in the JForumbaseServlet's init method class (variable defaultTemplatePath). But I doubt that changing the location of the templates directory has anything to do with this.

    Anything in the log files, either JForum or server?
     

    發表人: Amy
    6 年 前
    So there is no way to add jforum as a part of an existing webapp as a sub-directory? I tried adding freemarker.extra.template.path = ${application.path}/forum/templates in SytemGlobals.properties (because that was the next step in the init method after trying the default templates path). But it still returns an empty page (since I disabled CSRF - or else it just returned an error page for csrf validation).

    There were no logs recorded, I even tried adding a FileAppender in the log4j properties.




    會員註冊 / 登入  |  電腦版  |  Jump to top of page