我的第一个用maven构建的spring boot + angular项目如何定位首页?

东方一号蓝 2016-09-29 11:34:48
大家好。我用maven构建了一个spring boot 和angular的应用,项目结构如下:



spring boot可以正常启动,提示访问地址为:localhost:8080 。我想问怎么做才能实现,访问 “localhost:8080”就能跳转到index.html页面呢?就像一般的java web项目,部署到tomcat之后,访问"localhost:8080/project_name"就能自动定位到index.html。因为好像只有浏览器渲染了index.html,其中的ng-app才能被angular识别,angular才能启动。我能想到的有两种办法:
1.像tomcat那样,不会先到后台,直接定位到index.html。不知道是不是要配置什么?
2.在后端设置api为"/"的controller路径,然后返回字符串,想办法匹配到index.html。
求助!
...全文
556 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
街头小贩 2016-09-29
  • 打赏
  • 举报
回复
1.你把项目设为docbase

    <Host name="localhost"  appBase="webapps"  unpackWARs="true" autoDeploy="true">  
        <Context docBase="你的项目名" path="" reloadable="true"/>  
    </Host>  
2.把项目放到ROOT中或者直接打成ROOT.war,如果原来有ROOT文件夹把它删除掉 http://tomcat.apache.org/tomcat-8.5-doc/virtual-hosting-howto.html
引用
Contexts are normally located underneath the appBase directory. For example, to deploy the foobar context as a war file in the ren host, use $CATALINA_HOME/renapps/foobar.war. Note that the default or ROOT context for ren would be deployed as $CATALINA_HOME/renapps/ROOT.war (WAR) or $CATALINA_HOME/renapps/ROOT (directory). NOTE: The docBase for a context should never be the same as the appBase for a host.

10,607

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 其他
社区管理员
  • 其他
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧