actionresult

Struts 2 action method and struts.convention.result.path not working

别来无恙 提交于 2019-12-08 03:09:52
问题 I have problem with Struts2 action method and struts.convention.result.path Here is my struts.xml <struts> <constant name="struts.action.extension" value="" /> <constant name="struts.action.excludePattern" value="/.*\.(html|jsp),/static/.*"/> <constant name="struts.convention.result.path" value="/WEB-INF/pages/" /> <package name="user" namespace="/user" extends="struts-default"> <action name="login" class="loginAction" method="login"> <result name="success">login.jsp</result> </action> <

How to use Struts2 convention without using any action class

故事扮演 提交于 2019-12-07 15:24:23
问题 In Struts2 we can define action without using action class in struts.xml as follows: <action name="error"> <result>/error.jsp</result> </action> In my application I am using struts2 convention . In this case how to avoid writing action classes. I have many scenarios where I just want to go to the page without using any business logic. My result path is not just a JSP. I am using tiles. I am using code as follows: @Action(value="homePage", results={@Result(name="success", location="homePage",

ActionResult redirect renders using ToString()

别说谁变了你拦得住时间么 提交于 2019-12-07 14:39:21
问题 Using the following sample: http://www.west-wind.com/Weblog/posts/899303.aspx The following line... return req.RedirectingResponse.AsActionResult(); renders the string "DotNetOpenAuth.Messaging.OutgoingWebResponseActionResult". This is the class being returned as ActionResult in the line as posted. Does anyone know why I get the class name as string instead of a actual redirect? Thnx in advance! 回答1: Could it be that you have multiple versions of MVC in your Bin directory and your web server?

Bestpractice DI with ASP.NET MVC and StructureMap - How to inject dependencies in an ActionResult

杀马特。学长 韩版系。学妹 提交于 2019-12-07 13:03:10
问题 I edited my whole question, so do not wonder :) Well, I want to have an ActionResult that takes domain model data and some additional parameters, i.e page index and page size for paging a list. It decide itself if it returns a PartialViewResult or a ViewResult depending on the kind of web request (ajax request or not). The reffered data shall be mapped automatically by using an IMappingService, which is responsible for transforming any domain model data into a view model. The MappingService

Binding nested model with MVC3 on HttpPost

孤者浪人 提交于 2019-12-07 09:28:30
问题 I am new to MVC3. I have a submit button on a form and I want to bind a model which has 2-3 nested object models with many properties inside. Is there a way to bind these nested objects without using EditorFor; so that when I submit the form I will take on ActionResult(Object model) on model that is being returned, the nested object models with their values without having to implement hidden values or forms behind on html? 回答1: basically you need enough values to identify your model again. So

Struts 2 what to do when user inserts action which does not exist

两盒软妹~` 提交于 2019-12-06 14:05:34
In a Struts 2 application when user inserts an URL which is not related with any of your actions a java.lang.NullPointerException arises in these cases I want to display a nice screen so I have added in my struts.xml <global-exception-mappings> <exception-mapping exception="java.lang.NullPointerException" result="exception"/> </global-exception-mappings> <global-results> <result name="exception">/WEB-INF/jsp/exception.jsp</result> </global-results> but it doesn't work. I also have tried without success <action name="exception"> <result>/WEB-INF/jsp/exception.jsp</result> </action> so, I'm

ActionResult redirect renders using ToString()

拥有回忆 提交于 2019-12-05 23:50:22
Using the following sample: http://www.west-wind.com/Weblog/posts/899303.aspx The following line... return req.RedirectingResponse.AsActionResult(); renders the string "DotNetOpenAuth.Messaging.OutgoingWebResponseActionResult". This is the class being returned as ActionResult in the line as posted. Does anyone know why I get the class name as string instead of a actual redirect? Thnx in advance! Could it be that you have multiple versions of MVC in your Bin directory and your web server? It strikes me that if you had multiple assemblies (different versions) of the MVC types like ActionResult

Binding nested model with MVC3 on HttpPost

我只是一个虾纸丫 提交于 2019-12-05 13:21:59
I am new to MVC3. I have a submit button on a form and I want to bind a model which has 2-3 nested object models with many properties inside. Is there a way to bind these nested objects without using EditorFor; so that when I submit the form I will take on ActionResult(Object model) on model that is being returned, the nested object models with their values without having to implement hidden values or forms behind on html? basically you need enough values to identify your model again. So you can go with a Id in a hidden field and all the properties you want to change. To recreate your model

The parameters dictionary contains a null entry for parameter 'id' of non-nullable type

穿精又带淫゛_ 提交于 2019-12-05 03:00:15
问题 I'm trying to retrieve data from my db via the id parameter in my default route: routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); In this ActionResult I'm trying to render a custom user control, based on the route id parameter so that I retrieve the relevant data for the page that's requested public ActionResult InitPageNav(int id) { PageModel page =

How do I use Ninject with ActionResults while making the controller IoC-framework-agnostic?

送分小仙女□ 提交于 2019-12-05 02:46:27
问题 Nearly all of the Ninject examples I've seen explain how to use it with ASP.NET MVC, which will automatically inject dependencies into controllers. How would I use Ninject manually though? Let's say I have a custom ActionResult: public class JsonResult : ActionResult { [Inject] public ISerializer Serializer { get; set; } public JsonResult(object objectToSerialize) { // do something here } // more code that uses Serializer } Then in my controller, I'm using JsonResult in a method like this: