如果我建了一个web 项目叫myweb
请问如何在struts中设置我只要打入下面的地址
http://localhost:8080/myweb
就转到我的一个jsp页面 比如叫 login.jsp

解决方案 »

  1.   

    web.xml里面设置welcome-list即可,和STRUTS无关
      

  2.   

    <global-forwards>
        <forward name="myweb" path="/login.jsp" />
     </global-forwards>
      

  3.   

    方法一:
    在web.xml配置文件中找到 <welcome-file-list> 这一项,添加你的欢迎页面,如
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.html</welcome-file>
        <welcome-file>login.jsp</welcome-file>
      </welcome-file-list>二:不用修改web.xml,因为一般情况下会默认欢迎页面为index.jsp
    新建一个简单的JSP页面命名为 index.jsp ,里面只用写一句话
    <%
    response.sendRedirect(request.getContextPath()+"/login.jsp");
    %>
      

  4.   

    我喜欢这样:
    在web.xml配置文件中找到 <welcome-file-list> 这一项,添加你的欢迎页面,如
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.html</welcome-file>
        <welcome-file>login.jsp</welcome-file>
      </welcome-file-list>
      

  5.   

    各位大哥门我的不行啊
    我的index.jsp在WebRoot目录下
    web.xml在WebRoot里面的WEB-INF目录下
    而且里面有
    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    我的项目名字叫lovingpig
    我启动后输入
    http://localhost:8080/lovingpig但是不行啊
    有如下错误啊HTTP Status 404 - /lovingpig/--------------------------------------------------------------------------------type Status reportmessage /lovingpig/description The requested resource (/lovingpig/) is not available.
      

  6.   

    哈 我知道为什么了啊
    我的tomcat里面的server.xml中没有添加我这个项目的地址
    呵呵
    加了后就好了
    谢谢各位了啊