<legend id='2zF8O'><style id='2zF8O'><dir id='2zF8O'><q id='2zF8O'></q></dir></style></legend>
      1. <tfoot id='2zF8O'></tfoot>
          <bdo id='2zF8O'></bdo><ul id='2zF8O'></ul>
      2. <i id='2zF8O'><tr id='2zF8O'><dt id='2zF8O'><q id='2zF8O'><span id='2zF8O'><b id='2zF8O'><form id='2zF8O'><ins id='2zF8O'></ins><ul id='2zF8O'></ul><sub id='2zF8O'></sub></form><legend id='2zF8O'></legend><bdo id='2zF8O'><pre id='2zF8O'><center id='2zF8O'></center></pre></bdo></b><th id='2zF8O'></th></span></q></dt></tr></i><div id='2zF8O'><tfoot id='2zF8O'></tfoot><dl id='2zF8O'><fieldset id='2zF8O'></fieldset></dl></div>

        <small id='2zF8O'></small><noframes id='2zF8O'>

        如何从表单操作中调用客户 URL 操作?

        时间:2023-09-25

      3. <i id='0WJ6E'><tr id='0WJ6E'><dt id='0WJ6E'><q id='0WJ6E'><span id='0WJ6E'><b id='0WJ6E'><form id='0WJ6E'><ins id='0WJ6E'></ins><ul id='0WJ6E'></ul><sub id='0WJ6E'></sub></form><legend id='0WJ6E'></legend><bdo id='0WJ6E'><pre id='0WJ6E'><center id='0WJ6E'></center></pre></bdo></b><th id='0WJ6E'></th></span></q></dt></tr></i><div id='0WJ6E'><tfoot id='0WJ6E'></tfoot><dl id='0WJ6E'><fieldset id='0WJ6E'></fieldset></dl></div>
        <legend id='0WJ6E'><style id='0WJ6E'><dir id='0WJ6E'><q id='0WJ6E'></q></dir></style></legend>
            <tbody id='0WJ6E'></tbody>

              <small id='0WJ6E'></small><noframes id='0WJ6E'>

              <tfoot id='0WJ6E'></tfoot>

              • <bdo id='0WJ6E'></bdo><ul id='0WJ6E'></ul>

                1. 本文介绍了如何从表单操作中调用客户 URL 操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我关注了 这篇文章 并创建了一个自定义 URL 应用程序.动作被调用,但 url 显示会话 id 像

                  I followed this post and created a custom URL application. The action is getting called but the url shows with session id like

                  http://localhost:8080/CustomURL%7Busername%7D.action;jsessionid=9C1FB3EB633209C18625BBB40EA61000

                  我只想像 http://localhost:8080/CustomURL/rajesh

                  查看我的struts.xml:

                  <struts>
                  <constant name="struts.mapper.alwaysSelectFullNamespace"
                      value="false" />
                  <constant name="struts.enable.SlashesInActionNames" value="true" />
                  <constant name="struts.patternMatcher" value="namedVariable" />
                  <package name="default" namespace="/" extends="struts-default">
                      <action name="">
                          <result name="success">home.jsp</result>
                      </action>
                  
                      <action name="{username}" class="com.rajesh.struts2.CustomURL"
                          method="customUrl">
                          <result name="success">welcome.jsp</result>
                      </action>
                  
                  </package>
                  

                  查看我的 JSP 页面:

                  <%@ taglib prefix="s" uri="/struts-tags"%>
                  <html>
                  <head>
                  <title>Struts 2 Custom URL</title>
                  </head>
                  <body>
                      <h1>Struts 2 Custom URL</h1>
                      <h3>Enter your name below</h3>
                      <s:form action="{username}">
                          <s:textfield name="username" />
                          <s:submit />
                      </s:form>
                  </body>
                  </html>
                  

                  参见下面的 java 文件:

                  public class CustomURL extends ActionSupport {
                  
                      private String username;
                  
                      public String getUsername() {
                          System.out.println("Getter");
                          return username;
                      }
                  
                      public void setUsername(String username) {
                          System.out.println("Setter");
                          this.username = username;
                      }
                  
                      private static final long serialVersionUID = -4337790298641431230L;
                  
                      public String customUrl() {
                          return SUCCESS;
                      }
                  }
                  

                  推荐答案

                  首先你应该去掉动作扩展,如果你不想让用户认为他们的名字有扩展名.

                  First of all you should get rid of action extension, if you don't want user to think their name has an extension.

                  <constant name="struts.action.extension" value=",,action"/> 
                  

                  接下来的模式匹配器应该是regex.

                  Next the pattern matcher should be regex.

                  <constant name="struts.patternMatcher" value="regex"/>
                  

                  动作映射

                  <action name="/CustomURL/{username}" class="com.rajesh.struts2.CustomURL" method="customUrl">
                      <result name="success">welcome.jsp</result>
                  </action>
                  

                  在JSP 中你不需要使用form 标签,而是使用anchor 标签.并使用已知名称.

                  In the JSP you don't need to use form tag, but anchor tag. And use known names.

                  <a href="http://localhost:8080/CustomURL/rajesh">Click my name</a>
                  

                  这篇关于如何从表单操作中调用客户 URL 操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:双击提交按钮时如何避免两次插入两条相同的记录? 下一篇:使用拦截器验证用户访问权限

                  相关文章

                2. <i id='xJAvO'><tr id='xJAvO'><dt id='xJAvO'><q id='xJAvO'><span id='xJAvO'><b id='xJAvO'><form id='xJAvO'><ins id='xJAvO'></ins><ul id='xJAvO'></ul><sub id='xJAvO'></sub></form><legend id='xJAvO'></legend><bdo id='xJAvO'><pre id='xJAvO'><center id='xJAvO'></center></pre></bdo></b><th id='xJAvO'></th></span></q></dt></tr></i><div id='xJAvO'><tfoot id='xJAvO'></tfoot><dl id='xJAvO'><fieldset id='xJAvO'></fieldset></dl></div>
                    • <bdo id='xJAvO'></bdo><ul id='xJAvO'></ul>
                    1. <legend id='xJAvO'><style id='xJAvO'><dir id='xJAvO'><q id='xJAvO'></q></dir></style></legend>
                      <tfoot id='xJAvO'></tfoot>

                      <small id='xJAvO'></small><noframes id='xJAvO'>