Struts - Html:link

博客展示了HTML链接标签的使用,包含单参数和多参数情况。单参数通过paramId和paramName设置,多参数则使用HashMap存储float、int和string数组类型的值,并通过name属性传递,还给出了对应的URL示例。

  - <html:link action="/myAction" paramId="id" paramName="reqAttrId">LinkName</html:link>
    <a href="/context/module/editPrivilege.do?id=8">EDIT</a>
    8 is request.getAttribute("attrId")

  - <html:link action="/myAction" paramId="id" paramName="idBean" paramProperty="id">LinkName</html:link>
    <a href="/context/module/editPrivilege.do?id=8">EDIT</a>
    8 is [request|session|application].getAttribute("idBean").getId()

  - Multiple Parameters
   

<%
        java.util.HashMap newValues = new java.util.HashMap();
        newValues.put("floatProperty", new Float(444.0));
        newValues.put("intProperty", new Integer(555));
        newValues.put("stringArray", new String[] { "Value1", "Value2", "Value3" });
        pageContext.setAttribute("newValues", newValues);
    %>

    <html:link action="myAction" name="newValues">Float, int, and stringArray via name (Map)</html:link>

    http://localhost:8081/vic/editPrivilege.do?
    stringArray=Value1&stringArray=Value2&stringArray=Value3&floatProperty=444.0&intProperty=555

<%
        java.util.HashMap newValues = new java.util.HashMap();
        newValues.put("floatProperty", new Float(444.0));
        newValues.put("intProperty", new Integer(555));
        newValues.put("stringArray", new String[] { "Value1", "Value2", "Value3" });
        pageContext.setAttribute("newValues", newValues);
    %>

    <html:link action="myAction" name="newValues">Float, int, and stringArray via name (Map)</html:link>

    http://localhost:8081/vic/editPrivilege.do?
    stringArray=Value1&stringArray=Value2&stringArray=Value3&floatProperty=444.0&intProperty=555

<%
        java.util.HashMap newValues = new java.util.HashMap();
        newValues.put("floatProperty", new Float(444.0));
        newValues.put("intProperty", new Integer(555));
        newValues.put("stringArray", new String[] { "Value1", "Value2", "Value3" });
        pageContext.setAttribute("newValues", newValues);
    %>

    <html:link action="myAction" name="newValues">Float, int, and stringArray via name (Map)</html:link>

    http://localhost:8081/vic/editPrivilege.do?
    stringArray=Value1&stringArray=Value2&stringArray=Value3&floatProperty=444.0&intProperty=555

<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>健康咨询智能问答</title> <!-- 外部引入Bootstrap框架 --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"> <style> body { background-color: #f9fafb; font-family: 'Arial', sans-serif; } header { background-color: #4CAF50; color: white; padding: 1rem; text-align: center; } form { max-width: 600px; margin: 2rem auto; padding: 1.5rem; border-radius: 8px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); background-color: #ffffff; } label { display: block; margin-bottom: 0.5rem; font-weight: bold; } input[type="text"] { width: 100%; padding: 0.75rem; margin-bottom: 1rem; border: 1px solid #ced4da; border-radius: 4px; } button { width: 100%; padding: 0.75rem; background-color: #4CAF50; color: white; border: none; border-radius: 4px; cursor: pointer; transition: background-color 0.3s ease; } button:hover { background-color: #45a049; } h2 { text-align: center; margin-top: 1.5rem; } p { line-height: 1.6; text-align: justify; } </style> </head> <body> <header> <h1>健康咨询智能问答</h1> </header> <main> <form action="/ask" method="post"> <label for="user_input">请输入您的问题:</label> <input type="text" id="user_input" name="user_input" placeholder="例如:如何预防感冒?" required> <button type="submit">提交问题</button> </form> {% if user_input %} <section class="mt-4"> <h2>您提出的问题:</h2> <p>{{ user_input }}</p> {% if answer %} <h2>模型的回答如下:</h2> <p>{{ answer }}</p> {% endif %} </section> {% endif %} </main> </body> </html>基于这个代码 创建一个点击提交按钮后的子窗口
最新发布
05-12
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值