1

I am new to spring.My task is to do design and code for login and some CURD operations by using spring,hibernate and jsp.I need to pass list values from logincontroller to anothercontroller.

public ModelAndView loginProcess(HttpServletRequest request, HttpServletResponse response){  
          //..... 
          return new ModelAndView(new RedirectView("/dvd_hibernate/DvdController/dvdCURDOperation"),"userDetails",userDetails);}

I redirected to DvdController as well as passing userDetails.Is it the correct way to do?if so how to retrieve the userDetails value in anothercontroller? I didnot used annotations. please make me to clear.


NSSet error when adding record to core data (to-many relationship)

Ok so i'm still quite new to iOS and confused about a few things. Firstly, here are my entities... E.R.D

What i have already in there data wise is a Fruit (Apple) and a Source (Tree). They are both saved in the database.

Next i want to add an orange, but have the relationship with 'Tree'. So this is what i am using:

    Fruit *fruit = (Fruit *)[NSEntityDescription insertNewObjectForEntityForName:@"Fruit" inManagedObjectContext:managedObjectContext];
    fruit.fruitName = @"Orange";
  NSSet *test = [NSSet setWithObject:fruit];
    [_source addSourceFruit:test];

NSLog(@"4");

fruit.fruitSource = _source;

(_source is the 'Tree', I performed a fetch request for 'Tree' on the Source entity into an array, then took objectAtIndex:0 (Tree) and assigned it to a point towards source entity.

   data = [managedObjectContext executeFetchRequest:request error:&error];


   Source *_source = [data objectAtIndex:0];

and the accessor methods:

- (void)addSourceFruitObject:(Fruit *)value;
- (void)removeSourceFruitObject:(Fruit *)value;
- (void)addSourceFruit:(NSSet *)values;
- (void)removeSourceFruit:(NSSet *)values;

I have found an answer relating to bundles but i'm not entirely sure about them. I have read this 'https://developer.apple.com/library/mac/#documentation/CoreFOundation/Conceptual/CFBundles/AboutBundles/AboutBundles.html' and 'https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdAccessorMethods.html' but i just don't seem to be grasping it brilliantly.

EDIT: The error is

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSSet intersectsSet:]: set argument is not an NSSet'
*** First throw call stack:
4

3 に答える 3

2

あなたが探しているのはSpringのセッション変数だと思います。実際には4つの方法があり、それぞれに長所と短所があります。詳細については、次のリンクをご覧ください。これは、ネット上でこのトピックに関する最良の説明の1つを提供します。

RichardChesterwoodの「Springでのセッションの使用-MVC」

于 2012-12-10T11:42:42.920 に答える
1

loginProcess 内で直接 dvdCURDOperation メソッドを呼び出せないのはなぜですか。

ブラウザの URL が

/dvd_hibernate/DvdController/dvdCURDOperation

userDeatils を Session に保存し、dvdCURDOperation メソッドで取得する必要があります。

request.getSession.setAttribute("userDetails", userDetails);
return new ModelAndView("redirect:/dvd_hibernate/DvdController/dvdCURDOperation");
于 2012-12-10T10:38:20.750 に答える
0

すでにお気づきのことと思いますが、ModelMap を RedirectView に渡しても効果はありません。他の人はセッション変数について言及していますが、コントローラーをステートレスのままにしたい場合は、必要な引数を URL パラメーターとして渡すことができます。

于 2012-12-10T14:43:36.590 に答える