在Struts 2中从jsp传递值时出错

这是我的index.jsp

<%@page import="java.io.Console"%>
<%@page import="java.sql.*"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head> 
        <meta charset="UTF-8">
        <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js"></script>
        <script type="text/javascript">
            function editFunction(name) 
            {
                var f=document.form;
                f.method="post";
                f.action='Edit.jsp?name='+name;
                f.submit();             
            }
            function deleteFunction(name) 
            {
                var f=document.form;
                f.method="post";
                f.action='Delete.jsp?name='+name;
                f.submit();             
            }
        </script>
        <link rel="stylesheet" type="text/css" href="Style.css">

        <title>Global Market Model</title>

    </head>
<body>
    <div>
        <h1>Global Market Model</h1>        
        <div>               
            <s:form action="add" method="post">
                <s:textfield name="modelBean.modelname" label="Model Name:"></s:textfield>
                <s:submit/>                      
            </s:form>
        </div>
        <br>
        <div>
            <h3>Search: </h3>
        </div>      
        <div>
            <%
                Statement st=null;
                ResultSet rs=null;
                Connection con=null;
                try
                {

                    Class.forName("com.mysql.jdbc.Driver");

                    con= DriverManager.getconnection("jdbc:mysql://localhost:3306/test","root","root");
                    st=con.createStatement();
                    rs=st.executeQuery("select * from GLOBAL_MARKET_MODEL");
                    if (rs.equals(null))
                    {
                        out.print("Null set");
                    }
            %>
            <form name="form">
                <table id="table1" class ="table">
                    <thead align="center">
                        <tr>
                            <th>
                                Model Data
                            </th>                   
                        </tr>
                    </thead>                
                    <tr>
                        <th>ID</th>
                        <th>Model</th>
                        <th>Created By</th>
                        <th>Modified By</th>
                        <th>Created Time</th>
                        <th>Modified Time</th>
                        <th rowspan="2">activation Status</th>
                    </tr>
                    <tbody>
                        <%

                            while(rs.next())
                            {
                        %>
                                <tr>
                                    <td><%=rs.getInt("ID")%></td>
                                    <td><%=rs.getString("MODEL") %></td>
                                    <td><%=rs.getString("CREATED_BY") %></td>
                                    <td><%=rs.getString("MODIFIED_BY") %></td>
                                    <td><%=rs.getTime("CREATED_TIME") %></td>
                                    <td><%=rs.getTime("MODIFIED_TIME") %></td>
                                    <td><%=rs.getInt("actIVATION") %></td>                                  
                                    <td><input type="button" name="update" class="yellowButton" value="Update" onclick='editFunction("<%=rs.getString("MODEL")%>")'></td>
                                    <td><input type="button" name="delete" class="redButton" value="Delete" onclick='deleteFunction("<%=rs.getString("MODEL")%>")'></td>                                    
                                </tr>
                        <%
                            }

                        %>              
                    </tbody>                                                                
                </table>
            </form>
            <br>
            <%  
                }       
                catch(Exception exception)
                {
                    out.print("Hi from catch");
                    out.print(exception.getMessage());
                }

            %>      
        </div>

    </div>  
</body>
</html>

这是我的edit.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Edit Global Market Model</title>
    </head>
    <body>
        <s:form action="edit" method="post">
            <fieldset>
            <legend>Update</legend>
            <%
                String name= request.getParameter("name");
            %>
            Previous Name of Model is :
            <s:textfield name="modelBean.prevmodelname" label="Previous Model Name:" value="<%=name%>" readonly="readonly"></s:textfield>           
            <br>
            New Model Name:
            <s:textfield name="modelBean.modelname" label="New Model Name:"></s:textfield>          
            </fieldset>
            <br>
            <s:submit/>         
        </s:form>
    </body>
</html>

在运行程序时,单击更新按钮,它将转到Edit.jsp,但是在第19行出现以下错误“根据标签文件中的TLD或属性指令,属性[value]不接受任何表达式”基本上,这里,以前的模型名称将发送到Edit.jsp文件,在这里我们可以为其命名。 有人可以向我提供有关如何进行的帮助吗? 我正在使用struts 2框架。 P.s. Delete.jsp也存在相同的问题。

eeeeeeeeeeeeeeeeeed 回答:在Struts 2中从jsp传递值时出错

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2992508.html

大家都在问