zoukankan      html  css  js  c++  java
  • struts2设置默认首页

    在默认情况下,我们一般希望。当我们在浏览器中输入127.0.0.1:8080/project_name时候跳到项目的首页,那么在struts中我们这么设置呢?光加上<default-action-ref name="user" />是不够的,由于struts2默认是index.jsp为首页,所以我们把index.jsp删除了即可了,struts2从web.xml中找到项目的入口index.jsp可是index.jsp不存在了,那么<default-action-ref name="user" />这个配置就起作用了。user是你设置的action。

    以下给出我的配置

    <?xml version="1.0" encoding="UTF-8" ?

    > <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"> <struts> <constant name="struts.action.extension" value=",do,action" /> <constant name="struts.i18n.encoding" value="utf-8" /> <constant name="struts.devMode" value="true"></constant> <package name="front" namespace="/" extends="struts-default"> <default-action-ref name="user" /><!--在这里设置--> <action name="user" class="com.sunny.action.Login"> <result name="login">/login.jsp</result> </action> </package> </struts>


    然后我们在com.sunny.action.Login类中写一个execute函数就好了。注意这里能够不用继承ActionSupport,Struts2会通过反射技术,自己主动的调用我们自已写的execure函数。那么我们自已的默认首页就写好了

  • 相关阅读:
    codeforces 447C. DZY Loves Sequences 解题报告(446A)
    ajax 请求多张图片数据
    window 常用软件
    linux 脚本命令匹配并获取下一行数据
    linux C之getchar()非阻塞方式
    php curl 库使用
    vue.js 简单入门
    巧用jQuery选择器写表单办法总结(提高效率)
    linux 中断理解
    linux 驱动 工作队列
  • 原文地址:https://www.cnblogs.com/zhchoutai/p/6798714.html
Copyright © 2011-2022 走看看