在JSP中如何从URL获取参数?
例如,我有一个www.somesite.com/Transaction_List.jsp?accountID=5
我想要获得的URL 5.
是否有一个request.getAttribute("accountID")就像会话或类似的东西?
我有一个扩展方法:
public static class StringEx
{
public static bool Like(this string a, string b)
{
return a.ToLower().Contains(b.ToLower());
}
}
Run Code Online (Sandbox Code Playgroud)
如何使用我的参数通过GetMethod正确反映它?我试过这个没有成功(静态方法有例外):
var like = typeof(StringEx).GetMethod("Like", new[] {typeof(string), typeof(string)});
comparer = Expression.Call(prop, like, value);
Run Code Online (Sandbox Code Playgroud) 我注意到什么Html.BeginForm()方法编码提供routeValues到行动 FORM标签的属性.这适用于POST方法.但是如果方法是GET,则操作URL中的所有参数都被浏览器剥离(在IE8和Firefox 3.0.7上测试).
例如,这个代码在视图中
<%
using (Html.BeginForm("TestAction", "TestController", new { test = 123 },
FormMethod.Get))
{
Response.Write("<input type='submit'>");
};
%>
Run Code Online (Sandbox Code Playgroud)
给出了这样的HTML
<form action="/TestController/TestAction?test=123" method="get">
<input type='submit'>
</form>
Run Code Online (Sandbox Code Playgroud)
但提交表单后的URL变为/ TestController/TestAction而不是/ TestController/TestAction?test = 123(参数丢失).
现在我使用Html.Hidden()调用而不是routeValues参数,但我感兴趣的还有另一种解决方法吗?它应该被视为MVC中的错误,有时会被修复吗?
我试图找出一种方法来从一个表单用JavaScript读取GET方法信息.我们的IT部门使我们的服务器处于锁定状态,作为Web团队,我们只能使用javascript来完成我们的任务.如果可以的话,我会使用PHP,但我不能.
我需要做的是读取js中通过GET方法发送的数据(如果可能),这样我就可以将数据分配到变量中,并在用户对表单执行操作后在各个页面上使用它.
即.如果数据是在网址中发送的http://somesite.com?add_to_cart=true&items=10
任何帮助,将不胜感激!
我有以下网址 http://54.169.227.89:90/DataAccessService.svc/GetProducts/2 我想使用我改装获取方法如何追加2这是我在登录时从sharepreference获得的公司ID
这是ma接口代码
public interface ProductsGet {
String Company_id = OrderApplication.CompanyID_New;
@GET("/DataAccessService.svc/GetProducts/")
public void getProducts( Callback<List<ProductsNew>> response);
}
Run Code Online (Sandbox Code Playgroud) get-method ×5
.net ×1
android ×1
asp.net-mvc ×1
forms ×1
interface ×1
java ×1
javascript ×1
jquery ×1
jsp ×1
parameters ×1
php ×1
reflection ×1
retrofit ×1
static ×1
url ×1